Skip to content
Store model queries in cache and refer back to them later.
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Cacheable Behavior

Cacheable is a wrapper method for standard queries. It stores each query result under a unique key based on the find type and parameters in the cache when performed. If the cached data already exists, it will use it instead of querying the database again.

Cache is automatically wiped out for a model during the afterSave and afterDelete of that model. You will have to manually clear the cache for deepfinds however.


You must have the clear_cache plugin by Ceeram installed in order for this to work.


App_Model or Model:

var $actsAs = array('Cacheable.Cacheable');

Basic Usage

To use, simply substitute any instance of Model->find() with Model->cache(). That's all there is to it.

$data = $this->Model->cache($type, [$queryOptions = array(), [$options = array()]])
  • $type: the type of Model->find() [first, all, list, custom, etc]
  • $queryOptions: the options to pass to the Model->find()
  • $options: the cache() specific options
    • duration: cache duration (default is '1 hour')
    • update: forces the cached data to refresh (default false)


  • Place deepfind cache into subfolders. When manually clearing the cache from a related model, this will allow only a subset of the cache to be cleared instead.
Something went wrong with that request. Please try again.