class Ramaze::Cache::LocalMemCache

Cache based on the localmemcache library which utilizes mmap to share strings in memory between ruby instances.

Constants

OPTIONS

Public Instance Methods

cache_clear() click to toggle source

Wipe out all data in localmemcached, use with care.

# File lib/ramaze/cache/localmemcache.rb, line 30
def cache_clear
  @store.clear
end
cache_delete(*args) click to toggle source
Calls superclass method
# File lib/ramaze/cache/localmemcache.rb, line 34
def cache_delete(*args)
  super { |key| @store.delete(key.to_s); nil }
end
cache_fetch(*args) click to toggle source

NOTE:

* We have no way of knowing whether the value really is nil, we
  assume you wouldn't cache nil and return the default instead.
Calls superclass method
# File lib/ramaze/cache/localmemcache.rb, line 41
def cache_fetch(*args)
  super { |key|
    value = @store[key.to_s]
    @serializer.load(value) if value
  }
end
cache_setup(host, user, app, name) click to toggle source

Connect to localmemcache

# File lib/ramaze/cache/localmemcache.rb, line 20
def cache_setup(host, user, app, name)
  @namespace  = [host, user, app, name].compact.join('-')
  options     = {:namespace => @namespace}.merge(OPTIONS)

  @serialize  = options.delete(:serialize)
  @serializer = options.delete(:serializer)
  @store      = ::LocalMemCache.new(options)
end
cache_store(*args) click to toggle source
Calls superclass method
# File lib/ramaze/cache/localmemcache.rb, line 48
def cache_store(*args)
  super { |key, value| @store[key.to_s] = @serializer.dump(value) }
end