forked from e-oz/Memory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MemcachedDecorator.php
53 lines (44 loc) · 1.07 KB
/
MemcachedDecorator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace Jamm\Memory;
class MemcachedDecorator implements IMemcacheDecorator
{
/** @var \Memcached */
protected $memcached;
public function __construct($host = 'localhost', $port = 11211)
{
$this->memcached = new \Memcached();
$this->memcached->addServer($host, $port);
$this->memcached->setOption(\Memcached::OPT_COMPRESSION, true);
}
public function add($key, $var, $flag = null, $ttl = 0)
{
return $this->memcached->add($key, $var, $ttl);
}
public function delete($key)
{
return $this->memcached->delete($key);
}
public function get($key)
{
return $this->memcached->get($key);
}
public function increment($key, $by_value)
{
return $this->memcached->increment($key, $by_value);
}
public function set($key, $value, $flag = null, $ttl = 0)
{
return $this->memcached->set($key, $value, $ttl);
}
public function connect($host = 'localhost', $port = 11211)
{
}
public function getStats()
{
return $this->memcached->getStats();
}
public function decrement($key, $by_value)
{
return $this->memcached->decrement($key, $by_value);
}
}