extends class Phalcon\Cache\Frontend\Data
implements Phalcon\Cache\FrontendInterface
Allows to cache data converting/deconverting them to base64. This adapters uses the base64_encode/base64_decode PHP’s functions
// Cache the files for 2 days using a Base64 frontend $frontCache = new Phalcon\Cache\Frontend\Base64(array( "lifetime" => 172800 )); //Create a MongoDB cache $cache = new Phalcon\Cache\Backend\Mongo($frontCache, array( 'server' => "mongodb://localhost", 'db' => 'caches', 'collection' => 'images' )); // Try to get cached image $cacheKey = 'some-image.jpg.cache'; $image = $cache->get($cacheKey); if ($image === null) { // Store the image in the cache $cache->save($cacheKey, file_get_contents('tmp-dir/some-image.jpg')); } header('Content-Type: image/jpeg'); echo $image;
Serializes data before storing them
Unserializes data after retrieval
Phalcon\Cache\Frontend\Data constructor
Returns cache lifetime
Check whether if frontend is buffering output
Starts output frontend. Actually, does nothing
Returns output cached content
Stops output frontend
© 2011–2016 Phalcon Framework Team
Licensed under the Creative Commons Attribution License 3.0.
https://docs.phalconphp.com/en/2.0.0/api/Phalcon_Cache_Frontend_Base64.html