<?php require_once 'lib/SimpleCache.php'; $testCache = array( 'time' => time(), 'data' => 'Data. SimpleCache' ); $hash = 's<dds$%^frswfjkfbDS'; SimpleCache :: setup(SimpleCache :: FILE, array('cacheDir' => dirname(__FILE__) . '/cache/', 'hash' => $hash, 'compressed' => true)); SimpleCache :: setup(SimpleCache :: XCACHE, array('hash' => $hash, 'compressed' => true)); SimpleCache :: setup(SimpleCache :: MEMCACHED, array( 'hash' => 'asd23', 'compressed' => true, 'servers' => array(array( 'host' => 'localhost', 'port' => 11211, 'weight' => 1, 'persistent' => true ) ) ) ); //$cacheEngine = SimpleCache :: getEngine(SimpleCache :: MEMCACHED); $cacheEngine = SimpleCache :: getEngine(SimpleCache :: FILE); $cacheEngine = SimpleCache :: getEngine(SimpleCache :: XCACHE); echo '<pre>'; $cache = $cacheEngine->get('testKey'); if ($cache) { $memcachedCacheData = $cache; } else { $memcachedCacheData = array_merge($testCache, array('engine' => get_class($cacheEngine))); $cacheEngine->set('testKey', $memcachedCacheData, array('testTagOne'), 5); $cacheEngine->set('testKey2', array('testKey Cache Tag' => $testCache, $_SERVER), array('testTag', 'testTag2'), 5); } print_r($memcachedCacheData); $cacheEngine->set('testKey1', '1', array('testTag'), 5); $cacheEngine->set('testKey3', array($_SERVER, $_SERVER, $_SERVER, $_SERVER, $_SERVER), array('testTag2', 'testTag3'), 5); $cacheEngine->get('testKey'); $multiCache = $cacheEngine->multiLoad(array('testKey', 'testKey2')); print_r($multiCache);
$cacheEngine->deleteTag(array('testTag', 'testTag2')); var_dump($cacheEngine->get('testKey3')); //$cacheEngine->flush();
|