module Padrino
Public Class Methods
cache()
click to toggle source
Returns the caching engine.
@example
# with: Padrino.cache = Padrino::Cache.new(:File, :dir => /my/cache/path) Padrino.cache['val'] = 'test' Padrino.cache['val'] # => 'test' Padrino.cache.delete('val') Padrino.cache.clear
# File lib/padrino-cache.rb, line 19 def cache @_cache end
cache=(value)
click to toggle source
Set the caching engine.
@param value
Instance of Moneta store
@example
Padrino.cache = Padrino::Cache.new(:LRUHash) # default choice Padrino.cache = Padrino::Cache.new(:File, :dir => Padrino.root('tmp', app_name.to_s, 'cache')) # Keeps cached values in file Padrino.cache = Padrino::Cache.new(:Memcached) # Uses default server at localhost Padrino.cache = Padrino::Cache.new(:Memcached, :server => '127.0.0.1:11211', :exception_retry_limit => 1) Padrino.cache = Padrino::Cache.new(:Memcached, :backend => memcached_or_dalli_instance) Padrino.cache = Padrino::Cache.new(:Redis) # Uses default server at localhost Padrino.cache = Padrino::Cache.new(:Redis, :host => '127.0.0.1', :port => 6379, :db => 0) Padrino.cache = Padrino::Cache.new(:Redis, :backend => redis_instance) Padrino.cache = Padrino::Cache.new(:Mongo) # Uses default server at localhost Padrino.cache = Padrino::Cache.new(:Mongo, :backend => mongo_client_instance) # You can manage your cache from anywhere in your app: Padrino.cache['val'] = 'test' Padrino.cache['val'] # => 'test' Padrino.cache.delete('val') Padrino.cache.clear
# File lib/padrino-cache.rb, line 48 def cache=(value) @_cache= value end