Pluf_Cache Class Reference

Inheritance diagram for Pluf_Cache:

Pluf_Cache_Apc Pluf_Cache_File Pluf_Cache_Memcached

List of all members.

Public Member Functions

 set ($key, $value, $timeout=null)
 get ($key, $default=null)

Static Public Member Functions

static factory ()


Detailed Description

Cache class.

You should not use this class directly, but one of the subclasses implementing a given engine. This is done automatically when using the factory. It will use the engine defined by the 'cache_engine' configuration variable.

Default timeout in seconds is defined by the 'cache_timeout' configuration variable.

 $cache = new Pluf_Cache::factory();
 if (null === ($foo=$cache->get('my-key'))) {
     $foo = run_complex_operation();
     $cache->set('my-key', $foo);
 }
 return $foo;
 

The value to be stored in the cache must be serializable.

See also:
http://www.php.net/serialize

Member Function Documentation

static Pluf_Cache::factory (  )  [static]

Factory.

Returns:
Pluf_Cache_* Cache object

Pluf_Cache::set ( key,
value,
timeout = null 
)

Set a value in the cache.

Parameters:
string Key to store the information
mixed Value to store
int Timeout in seconds (null)
Returns:
bool Success

Reimplemented in Pluf_Cache_Apc, Pluf_Cache_File, and Pluf_Cache_Memcached.

Pluf_Cache::get ( key,
default = null 
)

Get value from the cache.

Parameters:
string Key to get the information
mixed Default value to return if cache miss (null)
mixed Stored value or default

Reimplemented in Pluf_Cache_Apc, Pluf_Cache_File, and Pluf_Cache_Memcached.


The documentation for this class was generated from the following file:

Generated on Wed Feb 3 15:44:51 2010 for Pluf by  doxygen