Skip to content

Instantly share code, notes, and snippets.

@Geolim4
Created September 17, 2016 00:25
Show Gist options
  • Save Geolim4/ae47518963b3253e6358c2599c009c6f to your computer and use it in GitHub Desktop.
Save Geolim4/ae47518963b3253e6358c2599c009c6f to your computer and use it in GitHub Desktop.
use phpFastCache\CacheManager;

$memCache = CacheManager::getInstance("memcached");
$redisCache = CacheManager::getInstance("redis");
$filesCache = CacheManager::getInstance("Files");

/**
* Get Items
*/
$memCacheItem1 = $memCache->getItem('item1');
$memCacheItem2 = $memCache->getItem('item2');
$memCacheItem3 = $memCache->getItem('item3');

$redisCacheItem1 = $redisCache->getItem('item1');
$redisCacheItem2 = $redisCache->getItem('item2');
$redisCacheItem3 = $redisCache->getItem('item3');

$filesCacheItem1 = $filesCache->getItem('item1');
$filesCacheItem2 = $filesCache->getItem('item2');
$filesCacheItem3 = $filesCache->getItem('item3');

/**
* Set Items
*/
$memCacheItem1->set('test1');
$memCacheItem2->set('test2');
$memCacheItem3->set('test3');

$redisCacheItem1->set('test1');
$redisCacheItem2->set('test2');
$redisCacheItem3->set('test3');

$filesCacheItem1->set('test1');
$filesCacheItem2->set('test2');
$filesCacheItem3->set('test3');

/**
* Save Items
*/
$memCache->save($memCacheItem1);
$memCache->save($memCacheItem2);
$memCache->save($memCacheItem3);

$redisCache->save($redisCacheItem1);
$redisCache->save($redisCacheItem2);
$redisCache->save($redisCacheItem3);

$filesCache->save($filesCacheItem1);
$filesCache->save($filesCacheItem2);
$filesCache->save($filesCacheItem3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment