Class: Riak::CacheStore
- Inherits:
-
ActiveSupport::Cache::Store
- Object
- ActiveSupport::Cache::Store
- Riak::CacheStore
- Defined in:
- lib/riak/cache_store.rb
Overview
An ActiveSupport::Cache::Store implementation that uses Riak. Compatible only with ActiveSupport version 3 or greater.
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #bucket ⇒ Object
- #delete_matched(matcher, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ CacheStore
constructor
Creates a Riak-backed cache store.
Constructor Details
#initialize(options = {}) ⇒ CacheStore
Creates a Riak-backed cache store.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/riak/cache_store.rb', line 13 def initialize( = {}) super @bucket_name = .delete(:bucket) || '_cache' @n_value = .delete(:n_value) || 2 @r = .delete(:r) || 1 @w = .delete(:w) || 1 @dw = .delete(:dw) || 0 @rw = .delete(:rw) || "quorum" @client = Riak::Client.new() set_bucket_defaults end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
10 11 12 |
# File 'lib/riak/cache_store.rb', line 10 def client @client end |
Instance Method Details
#bucket ⇒ Object
25 26 27 |
# File 'lib/riak/cache_store.rb', line 25 def bucket @bucket ||= @client.bucket(@bucket_name) end |
#delete_matched(matcher, options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/riak/cache_store.rb', line 29 def delete_matched(matcher, ={}) instrument(:delete_matched, matcher) do bucket.keys do |keys| keys.grep(matcher).each do |k| bucket.delete(k) end end end end |