mirror of
https://github.com/bilde2910/Hauk.git
synced 2026-07-28 18:21:22 +00:00
Support Redis; fixes #13
This commit is contained in:
parent
d3a0b02ad9
commit
c1ea1f1c18
5 changed files with 114 additions and 27 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue