Class: ActiveSupport::Cache::GibsonStore
- Inherits:
-
Store
- Object
- Store
- ActiveSupport::Cache::GibsonStore
- Defined in:
- lib/active_support/cache/gibson_store.rb
Overview
A cache store implementation which stores everything on the Gibson cache server.
GibsonStore implements the Strategy::LocalCache strategy which implements an in-memory cache inside of a block.
Instance Attribute Summary collapse
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#clear(options = nil) ⇒ Object
Deletes all items from the cache.
-
#decrement(name, amount = 1, options = nil) ⇒ Object
Decrements an already existing integer value that is stored in the cache.
-
#delete_matched(matcher, options = nil) ⇒ Object
Deletes multiple values by expression.
-
#increment(name, amount = 1, options = nil) ⇒ Object
Increments an already existing integer value that is stored in the cache.
-
#initialize(namespace, options) ⇒ GibsonStore
constructor
A new instance of GibsonStore.
-
#stats ⇒ Object
Returns some stats.
Constructor Details
#initialize(namespace, options) ⇒ GibsonStore
Returns a new instance of GibsonStore.
14 15 16 17 18 19 20 |
# File 'lib/active_support/cache/gibson_store.rb', line 14 def initialize( namespace, ) @options = .dup @namespace = namespace.to_s @gibson = Gibson::Client.new @options extend Strategy::LocalCache end |
Instance Attribute Details
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
11 12 13 |
# File 'lib/active_support/cache/gibson_store.rb', line 11 def namespace @namespace end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/active_support/cache/gibson_store.rb', line 12 def @options end |
Instance Method Details
#clear(options = nil) ⇒ Object
Deletes all items from the cache.
23 24 25 |
# File 'lib/active_support/cache/gibson_store.rb', line 23 def clear( = nil) @gibson.mdel @namespace + "::" end |
#decrement(name, amount = 1, options = nil) ⇒ Object
Decrements an already existing integer value that is stored in the cache.
36 37 38 39 40 41 |
# File 'lib/active_support/cache/gibson_store.rb', line 36 def decrement(name, amount = 1, = nil) key = (name) amount.times do |v| @gibson.dec key end end |
#delete_matched(matcher, options = nil) ⇒ Object
Deletes multiple values by expression
44 45 46 47 |
# File 'lib/active_support/cache/gibson_store.rb', line 44 def delete_matched(matcher, = nil) key = (matcher) @gibson.mdel key end |
#increment(name, amount = 1, options = nil) ⇒ Object
Increments an already existing integer value that is stored in the cache.
28 29 30 31 32 33 |
# File 'lib/active_support/cache/gibson_store.rb', line 28 def increment(name, amount = 1, = nil) key = (name) amount.times do |v| @gibson.inc key end end |
#stats ⇒ Object
Returns some stats
50 51 52 |
# File 'lib/active_support/cache/gibson_store.rb', line 50 def stats @gibson.stats end |