Class Phalcon\Cache\Frontend\Json

implements Phalcon\Cache\FrontendInterface

Allows to cache data converting/deconverting them to JSON. This adapter uses the json_encode/json_decode PHP’s functions As the data is encoded in JSON other systems accessing the same backend could process them

  1. <?php
  2. <?php
  3. // Cache the data for 2 days
  4. $frontCache = new \Phalcon\Cache\Frontend\Json(array(
  5. "lifetime" => 172800
  6. ));
  7. //Create the Cache setting memcached connection options
  8. $cache = new \Phalcon\Cache\Backend\Memcache($frontCache, array(
  9. 'host' => 'localhost',
  10. 'port' => 11211,
  11. 'persistent' => false
  12. ));
  13. //Cache arbitrary data
  14. $cache->save('my-data', array(1, 2, 3, 4, 5));
  15. //Get data
  16. $data = $cache->get('my-data');

Methods

public __construct ([unknown $frontendOptions])

Phalcon\Cache\Frontend\Base64 constructor

public integer getLifetime ()

Returns the cache lifetime

public boolean isBuffering ()

Check whether if frontend is buffering output

public start ()

Starts output frontend. Actually, does nothing

public string getContent ()

Returns output cached content

public stop ()

Stops output frontend

public string beforeStore (unknown $data)

Serializes data before storing them

public mixed afterRetrieve (unknown $data)

Unserializes data after retrieval