Support Redis; fixes #13

This commit is contained in:
Marius Lindvall 2019-09-17 12:44:28 +02:00
parent d3a0b02ad9
commit c1ea1f1c18
5 changed files with 114 additions and 27 deletions

View file

@ -8,28 +8,24 @@
class MemWrapper {
private $memcache = null;
function __construct($host, $port) {
function __construct() {
$this->memcache = new Memcache();
$this->memcache->connect(getConfig("memcached_host"), getConfig("memcached_port"))
or die ("Server could not connect to memcached!\n");
}
function get($key) {
$data = $this->memcache->get($key);
$data = $this->memcache->get(getConfig("memcached_prefix").$key);
if ($data === false) return false;
return json_decode($data, true);
}
function set($key, $data, $expire) {
$this->memcache->set($key, json_encode($data), 0, $expire);
}
function replace($key, $data, $expire) {
$this->memcache->replace($key, json_encode($data), 0, $expire);
$this->memcache->set(getConfig("memcached_prefix").$key, json_encode($data), 0, $expire);
}
function delete($key) {
$this->memcache->delete($key);
$this->memcache->delete(getConfig("memcached_prefix").$key);
}
}