ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# Class Phalcon\\Cache\\Frontend\\Json # 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 ``` <pre class="calibre14">``` <?php <?php // Cache the data for 2 days $frontCache = new \Phalcon\Cache\Frontend\Json(array( "lifetime" => 172800 )); //Create the Cache setting memcached connection options $cache = new \Phalcon\Cache\Backend\Memcache($frontCache, array( 'host' => 'localhost', 'port' => 11211, 'persistent' => false )); //Cache arbitrary data $cache->save('my-data', array(1, 2, 3, 4, 5)); //Get data $data = $cache->get('my-data'); ``` ``` ### Methods public **\_\_construct** (\[*array* $frontendOptions\]) Phalcon\\Cache\\Frontend\\Base64 constructor public **getLifetime** () Returns the cache lifetime public **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** (*mixed* $data) Serializes data before storing them public *mixed***afterRetrieve** (*mixed* $data) Unserializes data after retrieval | - [索引](# "总目录") - [下一页](# "Class Phalcon\Cache\Frontend\None") | - [上一页](# "Class Phalcon\Cache\Frontend\Igbinary") | - [API Indice](#) »