-
Notifications
You must be signed in to change notification settings - Fork 1
/
Apc.php
52 lines (46 loc) · 1.03 KB
/
Apc.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
<?php
require_once dirname(__FILE__) . '/Adapter.php';
class EventCacheAdapterApc extends EventCacheAdapter {
public function init () {
if (!function_exists('apc_cache_info')) {
return sprintf(
'APC not installed'
);
}
if (!ini_get('apc.enabled')) {
return sprintf(
'APC not enabled'
);
}
return true;
}
public function get ($key) {
return apc_fetch($key);
}
public function set ($key, $val, $ttl = 0) {
return apc_store($key, $val, $ttl);
// if (($got = apc_fetch($key)) !== $val) {
// trigger_error(sprintf(
// 'Unable to store %s with value: %s and TTL: %s in APC. Resulted in "%s"',
// $key,
// json_encode($val),
// $ttl,
// var_export($got, true)
// ), E_USER_WARNING);
// }
//
return true;
}
public function delete ($key) {
return apc_delete($key);
}
public function flush () {
return apc_clear_cache('user');
}
public function increment ($key, $val = 1) {
return apc_inc($key, $val);
}
public function decrement ($key, $val = 1) {
return apc_dec($key, $val);
}
}