This is the base class of zoglair cache managers. It defines all methods required so that switching among cache plugins is transparent. A descendant needs to override save() and load(). Their default definitions are to save and load items from memory, respectively.

A descendant of this class is instantiated as the globally available $zCahe object, based on the relevant system setting.

The following code snippet demonstrates how $zCahe is meant to be used:

global $zCahe;
  $t2l  = zCaheBase::Z_FOREVER; 
  $hash = $zCahe->hash('myData', $t2l); 
  $DATA = $zCahe->load($hash, $t2l);
  if (!$DATA) 
      ; // create $DATA 
      $zCahe->save($hash, $t2l, $DATA); 

Parent Class
Public Methods (4)
get_max_hash_len, hash, load, save
Protected Methods

integer get_max_hash_len()‎static

Returns the maximum length a hash() return value can have. This is currently 71 bytes.

The maximum hash length (in bytes)

string hash(mixed $name, mixed $t2l, mixed $args='')‎static

Generates a hash (~key) used by cache plugins to save/load data. The generated hash qualifies as an array key, filename or column value.

• An object, static method or any arbitrary string that represents the data owner or namespace. It must be of a node type. Object arguments are converted to strings via get_class().
• An integer or string to be used as an expiration time.
• Any data type that can be serialized. It is used as a $name instance.
The hash if all arguments are valid or zCaheBase::Z_INVALID_HASH if not.

mixed load(string $hash, mixed $t2l)‎

Loads data from cache, previously stored via save().

• A hash (~key) under which data were saved
• A t2l value, for validating data freshness. See hash() for its possible values.
The cached data or NULL if not exist or expired

void save(string $hash, mixed $t2l, mixed $data)‎

Saves data to cache, retreivable via load().

• A hash (~key) under which data will be saved. This must created via hash().
• A t2l value, for validating data freshness. See hash() for its possible values.
• Any type of data valid for serialize()
(C) Nick B. Cassos - All Rights Reserved
powered by zoglair
page generated in 118ms (11 queries, 14ms)