bitzer_store 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 721a1296290061a712d564f894cda9c30ad53ab3
4
- data.tar.gz: 9ed9482d546b1c4766daded40c314479c779bfcd
3
+ metadata.gz: 5a9e14bce8995255c65a616d6141e21454b1da83
4
+ data.tar.gz: 746433b546a4f6f869ce6da80a078c3fbee6393a
5
5
  SHA512:
6
- metadata.gz: 80b855e03b7e4d7cd13ea508230ad5afce4d1f3b0f9d938f8f5f70b541b392eb61998b433925c521208a90a669b663fa5d0fc4e05c403ec9c2e8dcb2d824e614
7
- data.tar.gz: 488eb5bf95e17cd4c58e1e2053ced8c53cb59e6b6f7163545e70851358923475a16d33366c99531921f25ec6d348e962a3c36dc0bd3446d18d1661401ab5d4f8
6
+ metadata.gz: 68972bf4a98ef1f6256e962f9fb0b6401b592544455d3bf2c5391f426b478b3a606d0b060b01a266ea3347f6b0a3c761103f04e09a920b4e6ad114f9c3769dcd
7
+ data.tar.gz: 8c4b8d999b58b0130c51490f25a5b1a9564ebb41c6aec1a5167b14634edeabb143b74b121a49caa0768de70c556aee11b52d9e6027722cf3c51037d43a9af65d
data/README.md CHANGED
@@ -1,11 +1,7 @@
1
1
  # BitzerStore
2
2
 
3
- BitzerStore can treat individual cache clusters in Rails.
4
- Rails cache normally uses one cache cluster.
5
-
6
- config.cache_store = :mem_cache_store, "server1", "server2"
7
-
8
- BitzerStore can use several named cache cluster.
3
+ The cache of Rails uses the cache cluster only one.
4
+ BitzerStore can treat multiple cache clusters.
9
5
 
10
6
  ## Installation
11
7
 
@@ -24,29 +20,67 @@ Or install it yourself as:
24
20
  ## Usage
25
21
 
26
22
  1.config
27
- at config/environments/*.rb
28
-
29
- config.cache_store = :bitzer_store, {
30
- :default => [:mem_cache_store, "server0"],
31
- :top_page => [:mem_cache_store, "server1", "server2"],
32
- :obj => [:dalli, "server3"],
33
- :footer => [:file_store, "/tmp"]
34
- }
35
-
36
- Each hash key is name of cache cluster.
37
- You should supply :default key which is used to default cache cluster.
23
+ at ```config/environments/*.rb```
24
+
25
+ ```ruby
26
+ MyApp::Application.configure do
27
+ BitzerStore.configure(config) do |cache|
28
+ cache.default :mem_cache_store, "server0"
29
+ cache.top_page :mem_cache_store, "server1", "server2"
30
+ cache.obj :dalli, "server3"
31
+ cache.footer :file_store, "/tmp"
32
+ end
33
+ end
34
+ ```
35
+
36
+ The ```xxx``` of ```cache.xxx``` is name of cache cluster.
37
+ You should supply ```cache.default``` which is used to cache cluster of default.
38
+
39
+ You can specify the setting common items.
40
+ Setting common items will be overwritten with individual setting.
41
+
42
+ ```ruby
43
+ MyApp::Application.configure do
44
+ BitzerStore.configure(config) do |cache|
45
+ cache.common_setting :memcache_store, "server0", :expires_in => 600
46
+ cache.default :namespace => "tsu"
47
+ cache.top_page :dalli, "server1"
48
+ end
49
+ end
50
+ ```
51
+
52
+ The contents of the above is the same as below.
53
+
54
+ ```ruby
55
+ MyApp::Application.configure do
56
+ BitzerStore.configure(config) do |cache|
57
+ cache.default :memcache_store, "server0", :expires_in => 600, :namespace => "tsu"
58
+ cache.top_page :dalli, "server1", :expires_in => 600
59
+ end
60
+ end
61
+ ```
38
62
 
39
63
  2.Rails.cache
40
64
  When specify no name, to use default cache cluster.
41
65
 
42
- Rails.cache.read("a")
66
+ ```ruby
67
+ Rails.cache.read("a")
68
+ ```
43
69
 
44
70
  Supply an options with a :sheep key. It's value is cache cluster name.
45
71
 
46
- Rails.cache.read("a", :sheep => :cluster_a)
72
+ ```ruby
73
+ Rails.cache.read("a", :sheep => :cluster_a)
74
+ ```
47
75
 
48
76
  caches_action, fragment_cache are the same.
49
77
 
78
+ ```ruby
79
+ <% cache "page", :sheep => :cluster_a do %>
80
+ <%= somethong %>
81
+ <% end %>
82
+ ```
83
+
50
84
  ## Contributing
51
85
 
52
86
  1. Fork it
@@ -19,7 +19,7 @@ module BitzerStore
19
19
  def set(name, *args)
20
20
  options = common_options.merge(args.extract_options!)
21
21
  args = args.presence || common_args
22
- args << options if options.present?
22
+ args = args + [options] if options.present?
23
23
 
24
24
  @settings[name] = args
25
25
  end
@@ -1,3 +1,3 @@
1
1
  module BitzerStore
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -4,24 +4,45 @@ describe BitzerStore::Configure do
4
4
  context "#set" do
5
5
  it "add settings" do
6
6
  c = BitzerStore::Configure.new
7
- c.set(:cache_name, :dalli, "localhost:11211", :expires_in => 600)
8
- expect(c.settings.keys.first).to eq(:cache_name)
9
- expect(c.settings.values.first).to eq([:dalli, "localhost:11211", :expires_in => 600])
7
+ c.set(:cache_name, :dalli, "localhost:11211", :expires_in => 600, :namespace => "tsu")
8
+ c.set(:cache_name2, :dalli, "localhost:11211", :expires_in => 600, :namespace => "oishi")
9
+ c.settings.each do |k, v|
10
+ case k
11
+ when :cache_name
12
+ expect(v).to eq([:dalli, "localhost:11211", :expires_in => 600, :namespace => "tsu"])
13
+ when :cache_name2
14
+ expect(v).to eq([:dalli, "localhost:11211", :expires_in => 600, :namespace => "oishi"])
15
+ end
16
+ end
10
17
  end
11
18
 
12
19
  it "use method_missing" do
13
20
  c = BitzerStore::Configure.new
14
- c.cache_name :dalli, "localhost:11211", :expires_in => 600
15
- expect(c.settings.keys.first).to eq(:cache_name)
16
- expect(c.settings.values.first).to eq([:dalli, "localhost:11211", :expires_in => 600])
21
+ c.cache_name :dalli, "localhost:11211", :expires_in => 600, :namespace => "tsu"
22
+ c.cache_name2 :dalli, "localhost:11211", :expires_in => 600, :namespace => "oishi"
23
+ c.settings.each do |k, v|
24
+ case k
25
+ when :cache_name
26
+ expect(v).to eq([:dalli, "localhost:11211", :expires_in => 600, :namespace => "tsu"])
27
+ when :cache_name2
28
+ expect(v).to eq([:dalli, "localhost:11211", :expires_in => 600, :namespace => "oishi"])
29
+ end
30
+ end
17
31
  end
18
32
 
19
33
  it "use common_setting" do
20
34
  c = BitzerStore::Configure.new
21
35
  c.common_setting :dalli, "localhost:11211", :expires_in => 600, :namespace => "tsuka"
22
36
  c.cache_name :namespace => "special"
23
- expect(c.settings.keys.first).to eq(:cache_name)
24
- expect(c.settings.values.first).to eq([:dalli, "localhost:11211", :expires_in => 600, :namespace => "special"])
37
+ c.cache_name2 :namespace => "oishi"
38
+ c.settings.each do |k, v|
39
+ case k
40
+ when :cache_name
41
+ expect(v).to eq([:dalli, "localhost:11211", :expires_in => 600, :namespace => "special"])
42
+ when :cache_name2
43
+ expect(v).to eq([:dalli, "localhost:11211", :expires_in => 600, :namespace => "oishi"])
44
+ end
45
+ end
25
46
  end
26
47
  end
27
48
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitzer_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - tsukasaoishi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-23 00:00:00.000000000 Z
11
+ date: 2014-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  version: '0'
133
133
  requirements: []
134
134
  rubyforge_project:
135
- rubygems_version: 2.2.2
135
+ rubygems_version: 2.2.0
136
136
  signing_key:
137
137
  specification_version: 4
138
138
  summary: BitzerStore can treat individual cache clusters in Rails.