bitzer_store 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +22 -0
- data/README.md +56 -0
- data/Rakefile +1 -0
- data/bitzer_store.gemspec +23 -0
- data/lib/active_support/cache/bitzer_store.rb +38 -0
- data/lib/bitzer_store.rb +1 -0
- data/lib/bitzer_store/version.rb +3 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2805ecf0924e8a2638b633c62bfe4c43d8a941fb
|
4
|
+
data.tar.gz: e14e69f32ed0a2f440dcaddae5c725b85704dbab
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 723259652890899d5245e45e14dbaa7e41bd53e2ff74d9e9fb9d56fab40cf9834e1ab120ea8fb588ff99222cfcc2147fe7929b7c7fc6afe750a5a2d6b5f83c41
|
7
|
+
data.tar.gz: c311045820e31cdf4d0198e732172fafa5eb0a2611c153bdf981713406300f075f18980786a6cf807c76fe684c06602987c0632feaa15ce2a75b806a1d19e013
|
data/.gitignore
ADDED
data/Gemfile
ADDED
File without changes
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Tsukasa OISHI
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# BitzerStore
|
2
|
+
|
3
|
+
BitzerStore can treat individual cache clusters in Rails.
|
4
|
+
Rails.cache uses one cache cluster.
|
5
|
+
|
6
|
+
config.cache_store = :mem_cache_store, "server1", "server2"
|
7
|
+
|
8
|
+
BitzerStore can use several named cache cluster.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'bitzer_store'
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install bitzer_store
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
1.config
|
27
|
+
at config/environments/xxx.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.
|
38
|
+
|
39
|
+
2.Rails.cache
|
40
|
+
When specify no name, to use default cache cluster.
|
41
|
+
|
42
|
+
Rails.cache.read("a")
|
43
|
+
|
44
|
+
Supply an options with a :sheep key. It's value is cache cluster name.
|
45
|
+
|
46
|
+
Rails.cache.read("a", :sheep => :cluster_a)
|
47
|
+
|
48
|
+
caches_action, fragment_cache are the same.
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
1. Fork it
|
53
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
54
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
55
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
56
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bitzer_store/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bitzer_store"
|
8
|
+
spec.version = BitzerStore::VERSION
|
9
|
+
spec.authors = ["tsukasaoishi"]
|
10
|
+
spec.email = ["tsukasa.oishi@gmail.com"]
|
11
|
+
spec.description = %q{BitzerStore can treat individual cache clusters in Rails.}
|
12
|
+
spec.summary = %q{BitzerStore can treat individual cache clusters in Rails.}
|
13
|
+
spec.homepage = "https://github.com/tsukasaoishi/bitzer_store"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module ActiveSupport
|
2
|
+
module Cache
|
3
|
+
class BitzerStore < Store
|
4
|
+
VERSION = Gem::Version.new("0.0.1")
|
5
|
+
PUBLIC_METHODS = %w|clanup clear read fetch delete exist? delete_matched write increment decrement|
|
6
|
+
PROTECTED_METHODS = %w|read_entry write_entry delete_entry|
|
7
|
+
|
8
|
+
def initialize(config)
|
9
|
+
raise ArgumentError, "BitzerStore needs default config. Supply a hash with a :default key." unless config.has_key?(:default)
|
10
|
+
|
11
|
+
@flocks = {}
|
12
|
+
config.each do |name, store_option|
|
13
|
+
@flocks[name.to_sym] = ActiveSupport::Cache.lookup_store(store_option)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
(PUBLIC_METHODS + PROTECTED_METHODS).each do |method_name|
|
18
|
+
class_eval <<-EVAL, __FILE__, __LINE__ + 1
|
19
|
+
def #{method_name}(*args, &block)
|
20
|
+
sheep(args.last).#{method_name}(*args, &block)
|
21
|
+
end
|
22
|
+
EVAL
|
23
|
+
end
|
24
|
+
|
25
|
+
protected *PROTECTED_METHODS
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def sheep(options)
|
30
|
+
@flocks[sheep_name(options)] || @flocks[:default]
|
31
|
+
end
|
32
|
+
|
33
|
+
def sheep_name(options)
|
34
|
+
(options && options.is_a?(Hash) && options[:sheep].presence || :default).to_sym
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/bitzer_store.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bitzer_store/version"
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bitzer_store
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- tsukasaoishi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: BitzerStore can treat individual cache clusters in Rails.
|
42
|
+
email:
|
43
|
+
- tsukasa.oishi@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- bitzer_store.gemspec
|
54
|
+
- lib/active_support/cache/bitzer_store.rb
|
55
|
+
- lib/bitzer_store.rb
|
56
|
+
- lib/bitzer_store/version.rb
|
57
|
+
homepage: https://github.com/tsukasaoishi/bitzer_store
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.0.0
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: BitzerStore can treat individual cache clusters in Rails.
|
81
|
+
test_files: []
|