Each adapter provides a consistent interface for the basic cache operations of write, read, delete, increment and decrement which can always be _used interchangeably_ between and must be implemented by all adapters. Functionality for clear, clean may or may not be implemented by an adapter. Calling a method that is not implemented will simply return false. An adapter may provide access to additional methods. It's always possible to call them directly. This allows a very wide range of flexibility, at the cost of portability. Cache::adapter('default')->methodName($argument); It is not guaranteed that all operations are atomic, but adapters will try to perform atomic operations wherever possible. If you rely on atomicity of operations you must choose an appropriate adapter that explitcly supports these. Adapters may handle serialization and/or multi-keys natively others only synthetically.
Inheritance: extends lithium\core\Object
Esempio n. 1
0
 /**
  * Constructor.
  *
  * @see lithium\storage\Cache::config()
  * @param array $config Configuration for this cache adapter. These settings are queryable
  *        through `Cache::config('name')`. The available options are as follows:
  *        - `'scope'` _string_: Scope which will prefix keys; per default not set.
  *        - `'expiry'` _mixed_: The default expiration time for cache values, if no value
  *          is otherwise set. Can be either a `strtotime()` compatible tring or TTL in
  *          seconds. To indicate items should not expire use `Cache::PERSIST`. Defaults
  *          to `+1 hour`.
  * @return void
  */
 public function __construct(array $config = array())
 {
     $defaults = array('scope' => null, 'expiry' => '+1 hour');
     parent::__construct($config + $defaults);
 }
Esempio n. 2
0
 /**
  * Determines if a given method can be called.
  *
  * @param string $method Name of the method.
  * @param boolean $internal Provide `true` to perform check from inside the
  *                class/object. When `false` checks also for public visibility;
  *                defaults to `false`.
  * @return boolean Returns `true` if the method can be called, `false` otherwise.
  */
 public function respondsTo($method, $internal = false)
 {
     if (parent::respondsTo($method, $internal)) {
         return true;
     }
     return is_callable(array($this->connection, $method));
 }
Esempio n. 3
0
 /**
  * Constructor.
  *
  * @see lithium\storage\Cache::config()
  * @param array $config Configuration for this cache adapter. These settings are queryable
  *        through `Cache::config('name')`. The available options are as follows:
  *        - `'scope'` _string_: Scope which will prefix keys; per default not set.
  *        - `'expiry'` _mixed_: The default expiration time for cache values, if no value
  *          is otherwise set. Can be either a `strtotime()` compatible tring or TTL in
  *          seconds. To indicate items should not expire use `Cache::PERSIST`. Defaults
  *          to `+1 hour`.
  *        - `'path'` _string_: Path where cached entries live, defaults to
  *          `Libraries::get(true, 'resources') . '/tmp/cache'`.
  * @return void
  */
 public function __construct(array $config = array())
 {
     $defaults = array('path' => Libraries::get(true, 'resources') . '/tmp/cache', 'scope' => null, 'expiry' => '+1 hour');
     parent::__construct($config + $defaults);
 }