Cache\Backend\Mongo

Class Phalcon\Cache\Backend\Mongo

extends abstract class Phalcon\Cache\Backend

implements Phalcon\Cache\BackendInterface

Allows to cache output fragments, PHP data or raw data to a MongoDb backend

// Cache data for 2 days
 $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'
 ));

 //Cache arbitrary data
 $cache->save('my-data', file_get_contents('some-image.jpg'));

 //Get data
 $data = $cache->get('my-data');

Methods

登录查看完整内容