Cache
class Cache (View source)
Cache::get('the-cache-key', function() { # this gets executed when cache is stale return "your cacheable datas"; });
Properties
static | $adapter | ||
static | $options |
Methods
Initializes the cache.
No description
Attempt to retrieve a value from cache using a key. If the value is not found, then the closure method will be invoked, and the result will be stored in cache using that key.
No description
No description
Details
at line 40
static
initialize(string $url, array $options = array())
Initializes the cache.
With the $options array it's possible to define: - expiration of the key, (time in seconds) - a namespace for the key
this last one is useful in the case two applications use a shared key/store (for instance a shared Memcached db)
Ex: $cfg_ar = ActiveRecord\Config::instance(); $cfg_ar->set_cache('memcache://localhost:11211',array('namespace' => 'my_cool_app', 'expire' => 120 ));
In the example above all the keys expire after 120 seconds, and the all get a postfix 'my_cool_app'.
(Note: expiring needs to be implemented in your cache store.)
at line 56
static
flush()
at line 70
static mixed
get($key, $closure, $expire = null)
Attempt to retrieve a value from cache using a key. If the value is not found, then the closure method will be invoked, and the result will be stored in cache using that key.