php - use memcache for fragment cache -
how use memcache fragment cache? use zend framework libraries. see exapmle.
require_once 'zend/cache.php'; $frontendoptions = array( 'lifetime' => 300, 'automatic_serialization' => false ); $backendoptions = array('cache_dir' => './zendcache/'); $cache = zend_cache::factory('output', 'file', $frontendoptions, $backendoptions); if (!$cache->start('rightcolumn')) { // html , cached in file. $cache->end(); }
now want use memcache fragment cache.
require_once 'zend/cache.php'; $frontend = array('caching' => true, 'lifetime' => 1800, 'automatic_serialization' => true); $backendoptions = array('cache_dir' => './zendcache/'); $backend = array( 'servers' => array( array('host' => '127.0.0.1', 'port' => 11211) ), 'compression' => false ); $cache = zend_cache::factory('core', 'memcached', $frontend, $backend); $key = 'cachekey'; if (($result = $cache->load($key)) === false) { $cache->save($result, $key); } echo $result;
how solve ?
Comments
Post a Comment