Class: ActiveSupport::Cache::GibsonStore

Inherits:
Store
  • Object
show all
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

Instance Method Summary collapse

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 )
  @options = options.dup
  @namespace = namespace.to_s
  @gibson = Gibson::Client.new @options 

  extend Strategy::LocalCache
end

Instance Attribute Details

#namespaceObject (readonly)

Returns the value of attribute namespace.



11
12
13
# File 'lib/active_support/cache/gibson_store.rb', line 11

def namespace
  @namespace
end

#optionsObject (readonly)

Returns the value of attribute options.



12
13
14
# File 'lib/active_support/cache/gibson_store.rb', line 12

def options
  @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(options = 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, options = nil)
  key = expand_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, options = nil)
  key = expand_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, options = nil)
  key = expand_key(name)
  amount.times do |v|
    @gibson.inc key
  end
end

#statsObject

Returns some stats



50
51
52
# File 'lib/active_support/cache/gibson_store.rb', line 50

def stats
  @gibson.stats
end