Class: Riak::CacheStore
- Inherits:
-
ActiveSupport::Cache::Store
- Object
- ActiveSupport::Cache::Store
- Riak::CacheStore
- Defined in:
- riak-client/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)
-
- (Object) client
Returns the value of attribute client.
Instance Method Summary (collapse)
- - (Object) bucket
- - (Object) delete_matched(matcher, options = {})
-
- (CacheStore) initialize(options = {})
constructor
Creates a Riak-backed cache store.
Constructor Details
- (CacheStore) initialize(options = {})
Creates a Riak-backed cache store.
35 36 37 38 39 40 41 42 43 44 45 |
# File 'riak-client/lib/riak/cache_store.rb', line 35 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
- (Object) client
Returns the value of attribute client
32 33 34 |
# File 'riak-client/lib/riak/cache_store.rb', line 32 def client @client end |
Instance Method Details
- (Object) bucket
47 48 49 |
# File 'riak-client/lib/riak/cache_store.rb', line 47 def bucket @bucket ||= @client.bucket(@bucket_name, :keys => false) end |
- (Object) delete_matched(matcher, options = {})
51 52 53 54 55 56 57 58 59 |
# File 'riak-client/lib/riak/cache_store.rb', line 51 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 |