-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMemcached.php
48 lines (41 loc) · 1.35 KB
/
Memcached.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
<?php
/**
* class implements MemcacheInterface if Memcached available in system
*
* @author val@filin.us
*/
namespace PhishCheck;
class Memcached extends \Memcached implements namespace\MemcacheInterface {
function __construct(array $options=array()) {
parent::__costruct();
$this->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
$this->setOption(\Memcached::OPT_RETRY_TIMEOUT, 1 );
$this->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true );
$this->setOption(\Memcached::OPT_TCP_NODELAY, true);
}
public function get($key) {
return parent::get($key, null, $cas);
}
/**
* raises exception if there were some non-data manipulation result code
*
* @return bool
* @throws MemcacheFatalError
*/
public function isSafeMemcacheError() {
$mcResultCode = $this->getResultCode();
if (in_array($mcResultCode, array(
\Memcached::RES_SUCCESS,
\Memcached::RES_STORED,
\Memcached::RES_DELETED,
\Memcached::RES_DATA_EXISTS,
\Memcached::RES_NOTFOUND,
\Memcached::RES_NOTSTORED,
\Memcached::RES_END,
\Memcached::RES_BUFFERED
))) {
return true;
}
throw new namespace\MemcacheFatalError('Memcache Fatal Error ', $mcResultCode);
}
}