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
|
<?php
|
||||||
namespace Makai\Whois;
|
namespace Makai\Whois;
|
||||||
|
|
||||||
|
use Memcached;
|
||||||
use Index\Routing\Route;
|
use Index\Routing\Route;
|
||||||
use Index\Routing\RouteHandler;
|
use Index\Routing\RouteHandler;
|
||||||
use Sasae\SasaeEnvironment;
|
use Sasae\SasaeEnvironment;
|
||||||
|
@ -44,15 +45,14 @@ class WhoisRoutes extends RouteHandler {
|
||||||
$source = '';
|
$source = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$redis = new \Redis;
|
$cache = new Memcached;
|
||||||
$redis->connect('/var/run/redis/redis-server.sock');
|
$cache->addServer('localhost', 11211);
|
||||||
|
|
||||||
$result = $redis->get($prefix . $hash);
|
$result = $cache->get($prefix . $hash);
|
||||||
|
if($result === false) {
|
||||||
if(empty($result)) {
|
|
||||||
$client = new WhoisClient;
|
$client = new WhoisClient;
|
||||||
$result = $client->lookup($target);
|
$result = $client->lookup($target);
|
||||||
$redis->setEx($prefix . $hash, 1800, serialize($result));
|
$cache->set($prefix . $hash, serialize($result), 1800);
|
||||||
$source = 'fresh';
|
$source = 'fresh';
|
||||||
} else {
|
} else {
|
||||||
$result = unserialize($result);
|
$result = unserialize($result);
|
||||||
|
|
Loading…
Reference in a new issue