class ActiveSupport::Cache::GibsonStore

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.

Attributes

namespace[R]
options[R]

Public Class Methods

new( namespace, options ) click to toggle source
# 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

Public Instance Methods

clear(options = nil) click to toggle source

Deletes all items from the cache.

# File lib/active_support/cache/gibson_store.rb, line 23
def clear(options = nil)
  begin
    @gibson.mdel @namespace + "::"
  rescue
    0
  end
end
decrement(name, amount = 1, options = nil) click to toggle source

Decrements an already existing integer value that is stored in the cache.

# File lib/active_support/cache/gibson_store.rb, line 45
def decrement(name, amount = 1, options = nil)
  key = expand_key(name)

  begin
    amount.times do |v|
      @gibson.dec key
    end
  rescue

  end
end
delete_matched(matcher, options = nil) click to toggle source

Deletes multiple values by expression

# File lib/active_support/cache/gibson_store.rb, line 58
def delete_matched(matcher, options = nil)
  key = expand_key(matcher)

  begin
    @gibson.mdel key
  rescue
    0
  end
end
increment(name, amount = 1, options = nil) click to toggle source

Increments an already existing integer value that is stored in the cache.

# File lib/active_support/cache/gibson_store.rb, line 32
def increment(name, amount = 1, options = nil)
  key = expand_key(name)

  begin
    amount.times do |v|
      @gibson.inc key
    end
  rescue

  end
end
stats() click to toggle source

Returns some stats

# File lib/active_support/cache/gibson_store.rb, line 69
def stats
  @gibson.stats
end

Protected Instance Methods

delete_entry(key, options) click to toggle source
# File lib/active_support/cache/gibson_store.rb, line 101
def delete_entry(key, options)
  key = expand_key(key)

  begin
    @gibson.del key

    true
  rescue
    false
  end
end
read_entry(key, options) click to toggle source
# File lib/active_support/cache/gibson_store.rb, line 75
def read_entry(key, options)
  key = expand_key(key)

  begin
    cached = @gibson.get key

    Marshal.load(cached)
  rescue Gibson::NotFoundError
    nil
  end
end
write_entry(key, entry, options) click to toggle source
# File lib/active_support/cache/gibson_store.rb, line 87
def write_entry(key, entry, options)
  e = Marshal.dump(entry)

  key = expand_key(key) 

  begin
    @gibson.set( options[:expires_in].to_i, key, e )
    
    true
  rescue
    false
  end
end

Private Instance Methods

expand_key(v) click to toggle source
# File lib/active_support/cache/gibson_store.rb, line 115
def expand_key(v)
  @namespace + "::" + v.to_s.tr( ' ', '_' )
end