## Class mr_cache

Description

MR Cache

A basic caching class to cache data across sessions and page requests.

- author: Mark Nielsen
- example: See the cache in action

Located in /cache.php (line 46)

Class Constant Summary
BACKEND = 'Memcached'
FRONTEND = 'Core'
Variable Summary
Zend_Cache $cache
Method Summary
mr_cache __construct ([string $prefix = NULL])
boolean clean ()
mixed load (string $id, [boolean $unserialize = false])
boolean remove (string $id)
boolean save (mixed $data, [string $id = null])
boolean test (string $id)
boolean touch (string $id, int $extraLifetime)
Variables
Zend_Cache $cache = false (line 63)

Cache object

- access: protected

Methods
Constructor __construct (line 70)

Constructor - create a new interface to the cache

- access: public

mr_cache __construct ([string $prefix = NULL])

- string $prefix: Prefix all cache IDs with this string

clean (line 198)

Clean all cache entries

- throws: coding_exception
- access: public

boolean clean ()
load (line 115)

Test if a cache is available for the given id and (if yes) return it (false else)

Pass true as second param if you cached data that does not pass the is_string() check

- throws: coding_exception
- access: public

mixed load (string $id, [boolean $unserialize = false])

- string $id: Cache ID
- boolean $unserialize: Automatically unserialize the cached result

remove (line 181)

Remove a cached item

- throws: coding_exception
- access: public

boolean remove (string $id)

- string $id: Cache ID

save (line 160)

Save data to the cache

- throws: coding_exception
- access: public

boolean save (mixed $data, [string $id = null])

- mixed $data: The data to be saved, if data fails is_string() check, then it will be serialized. You then must unserialize it when it is retrieved from cache or call the load method like so: $cache->load('cacheId', true);
- string $id: Cache id (if not set, the last cache id will be used)

test (line 139)

Test if a cache is available for the given id

- throws: coding_exception
- access: public

boolean test (string $id)

- string $id: Cache ID

touch (line 217)

Give (if possible) an extra lifetime to the given cache id

- throws: coding_exception
- access: public

boolean touch (string $id, int $extraLifetime)

- string $id: Cache ID
- int $extraLifetime: The time to add to the life

Class Constants
BACKEND = 'Memcached' (line 56)

Cache storage

FRONTEND = 'Core' (line 51)

Cache interface

Documentation generated on Thu, 28 Jun 2012 16:33:47 -0700 by phpDocumentor 1.4.3