public mixed Solar_Cache_Adapter::fetch ( string $key )

Gets cache entry data.


  • (string) $key: The entry ID.


  • (mixed) Boolean false on failure, string on success.


Gets cache entry data.

Use this to retrieve the cache entry identifed by key. The key can be any scalar value: a web page name, an integer ID, a simple name, and so on.

If the cache entry does not exist, or if it has passed its lifetime (defined in the adapter's config keys), the function will return boolean false; otherwise, it will return the contents of the cache entry.

For example, to get a cache entry identified by a web page name, you could do this ...

// create a request object
$request = Solar_Registry::get('request');

// get the request URI as an identifier
$id = $request->server('REQUEST_URI');

// create a cache object
$cache = Solar::factory('Solar_Cache');

// fetch the result and dump it to screen
$result = $cache->fetch($id);