ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# Class Phalcon\\Cache\\Frontend\\Base64 # Class **Phalcon\\Cache\\Frontend\\Base64** *implements*[*Phalcon\\Cache\\FrontendInterface*](#) Allows to cache data converting/deconverting them to base64. This adapter uses the base64\_encode/base64\_decode PHP's functions ``` <pre class="calibre14">``` <?php <?php // 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; ``` ``` ### 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 in this adapter 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\Data") | - [上一页](# "Class Phalcon\Cache\Exception") | - [API Indice](#) »