Abstract Class Misago\ActiveSupport\Cache\Store

Abstract cache storage.

See Misago\ActiveSupport\MemoryStore, Misago\ActiveSupport\MemcacheStore, Misago\ActiveSupport\RedisStore or Misago\ActiveSupport\FileStore for actual implementations. You may also build your own one.

Note: Misago\ActiveSupport\Cache is meant to store strings. Some implementations may store something else (like objects), but that shouldn't be used.

Inheritence

Extends:
Misago

Methods

Public static methods

singleton()

Public instance methods

__invoke($key, $closure, $options=array())

Transparently gets data, either already cached or to generated by the closure (which is supposed to return the data).

For example, in your ActionController:

class UsersController extends ApplicationController
{
  function show()
  {
    $id   = $this->params[':id'];
    $user = $this->cache("cache_key", function() use($id) {
       return User::find($id);
    });
  }
} 

decrement($key, $amount=1)

Decrements a variable by $amount.

fetch($key, $default=null)

Gets a variable if available, otherwise returns $default.

read($key)

Gets a variable.

$user_id = $store->read('user_id');
list($user_id, $user_name) = $store->read(array('user_id', 'user_name')); 

Protected instance methods

ttl($options)

Generates the time-to-live from expires_in or expires_at options.