Class: Merb::Cache

Class | Merb::Cache
In: | lib/merb-cache/cache-action.rb lib/merb-cache/cache-page.rb lib/merb-cache/merb-cache.rb
Parent: | Object

### Methods

expire_key_for key_for start

### Classes and Modules

Module Merb::Cache::ControllerClassMethods
Module Merb::Cache::ControllerInstanceMethods
Module Merb::Cache::DatabaseStore
Class Merb::Cache::DatabaseStore
Class Merb::Cache::DummyStore
Class Merb::Cache::FileStore
Class Merb::Cache::MemcacheStore
Class Merb::Cache::MemoryStore

### Constants

DEFAULT_CONFIG | = | { :cache_html_directory => Merb.dir_for(:public) / "cache", #:store => "database", #:table_name => "merb_cache", #:disable => "development", # disable merb-cache in development #:disable => true, # disable merb-cache in all environments :store => "file", :cache_directory => Merb.root_path("tmp/cache"), #:store => "memcache", #:host => "127.0.0.1:11211", #:namespace => "merb_cache", #:track_keys => true, #:store => "memory", # store could be: file, memcache, memory, database, dummy, ... }

### Attributes

config | [R] |
store | [R] |

### Public Instance methods

expire_key_for(options, controller, controller_based = false) {|key, !options[:match].nil?| ...}

Compute a cache key and yield it to the given block It is used by the expire_page, expire_action and expire methods.

#### Parameters

options<String, Hash>: | The key or the Hash that will be used to build the key
controller<String>: | The name of the controller
controller_based<Boolean>: | only used by action and page caching

#### Options (options)

:key<String>: | The complete or partial key that will be computed.
:action<String>: | The action name that will be used to compute the key
:controller<String>: | The controller name that will be part of the key
:params<Array[String]>: | The params will be joined together (with ’/’) and added to the key
:match<Boolean, String>: | true, it will try to match multiple cache entries string, shortcut for {:key => "mykey", :match => true}

#### Examples

      expire(:key => "root_key", :params => [session[:me], params[:id]])
      expire(:match => "root_key")
      expire_action(:action => 'list')
      expire_page(:action => 'show', :controller => 'news')

#### Returns

The result of the given block

key_for(options, controller, controller_based = false)

Compute a cache key based on the given parameters Only used by the cached_page?, cached_action?, cached?, cache, cache_get and cache_set methods

#### Parameters

options<String, Hash>: | The key or the Hash that will be used to build the key
controller<String>: | The name of the controller
controller_based<Boolean>: | only used by action and page caching

#### Options (options)

:key<String>: | The complete or partial key that will be computed.
:action<String>: | The action name that will be used to compute the key
:controller<String>: | The controller name that will be part of the key
:params<Array[String]>: | The params will be joined together (with ’/’) and added to the key

#### Examples

      cache_set("my_key", @data)
      cache_get(:key => "root_key", :params => [session[:me], params[:id]])

#### Returns

The computed key

start()

Called in the after_app_loads loop and instantiate the right backend

#### Raises

Store#NotFound: | If the cache_store mentionned in the config is unknown

[Validate]