Replaced Redis with Memcached.

This commit is contained in:
flash 2024-03-25 20:37:13 +00:00
parent 1a0b0ca01c
commit dc012fa8a6

View file

@ -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);