Last active
July 10, 2017 13:24
-
-
Save gsouf/22795a9e3aa7acb4e72a5ad14f25219b to your computer and use it in GitHub Desktop.
phpcache-redis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include __DIR__ . '/vendor/autoload.php'; | |
$redis = new Redis(); | |
$redis->connect('127.0.0.1', 6379); | |
$pool = new \Cache\Adapter\Redis\RedisCachePool($redis); | |
$key = '|NS|foo|bar'; | |
$time = 1000; | |
$item = $pool->getItem($key); | |
if (!$item->isHit()) { | |
echo 'miss'; | |
$item->set('bar'); | |
$item->expiresAfter($time); | |
$pool->save($item); | |
} else { | |
echo 'hit'; | |
} | |
echo PHP_EOL; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include __DIR__ . '/vendor/autoload.php'; | |
$redis = new Redis(); | |
$redis->connect('127.0.0.1', 6379); | |
$pool = new \Cache\Adapter\Redis\RedisCachePool($redis); | |
$key = '|NS|foo'; | |
$item = $pool->deleteItem($key); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment