class Ramaze::Cache::LRU
Cache class that uses {Ramaze::LRUHash} as a storage engine. This cache has the advantage that unlike Innate::Cache::Memory it does not leak memory over time when using the cache for sessions.
@example
Ramaze::Cache.options.session = Ramaze::Cache::LRU Ramaze.setup_dependencies
@author Michael Fellinger @since 17-07-2009
Constants
- OPTIONS
Hash containing all the options for the cache.
Public Instance Methods
Clears the entire cache.
@author Michael Fellinger @since 17-07-2009
# File lib/ramaze/cache/lru.rb, line 50 def cache_clear @store.clear end
Deletes a set of data from the cache
@author Michael Fellinger @since 17-07-2009 @see Innate::Cache::API#cache_delete
# File lib/ramaze/cache/lru.rb, line 83 def cache_delete(*args) super { |key| @store.delete(key) } end
Retrieves a set of data from the cache.
@author Michael Fellinger @since 17-07-2009 @see Innate::Cache::API#cache_fetch
# File lib/ramaze/cache/lru.rb, line 72 def cache_fetch(*args) super { |key| @store[key] } end
Prepares the cache by creating a new instance of Ramaze::LRUHash using the options set in {Ramaze::Cache::LRU::OPTIONS}.
@author Michael Fellinger @since 17-07-2009
# File lib/ramaze/cache/lru.rb, line 40 def cache_setup(host, user, app, name) @store = Ramaze::LRUHash.new(OPTIONS) end
Stores a set of data in the cache.
@author Michael Fellinger @since 17-07-2009 @see Innate::Cache::API#cache_store
# File lib/ramaze/cache/lru.rb, line 61 def cache_store(*args) super { |key, value| @store[key] = value } end