Replaced Redis with Memcached.
This commit is contained in:
parent
1a0b0ca01c
commit
dc012fa8a6
1 changed files with 6 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
namespace Makai\Whois;
|
||||
|
||||
use Memcached;
|
||||
use Index\Routing\Route;
|
||||
use Index\Routing\RouteHandler;
|
||||
use Sasae\SasaeEnvironment;
|
||||
|
@ -44,15 +45,14 @@ class WhoisRoutes extends RouteHandler {
|
|||
$source = '';
|
||||
|
||||
try {
|
||||
$redis = new \Redis;
|
||||
$redis->connect('/var/run/redis/redis-server.sock');
|
||||
$cache = new Memcached;
|
||||
$cache->addServer('localhost', 11211);
|
||||
|
||||
$result = $redis->get($prefix . $hash);
|
||||
|
||||
if(empty($result)) {
|
||||
$result = $cache->get($prefix . $hash);
|
||||
if($result === false) {
|
||||
$client = new WhoisClient;
|
||||
$result = $client->lookup($target);
|
||||
$redis->setEx($prefix . $hash, 1800, serialize($result));
|
||||
$cache->set($prefix . $hash, serialize($result), 1800);
|
||||
$source = 'fresh';
|
||||
} else {
|
||||
$result = unserialize($result);
|
||||
|
|
Loading…
Reference in a new issue