-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmfwApc.php
53 lines (42 loc) · 996 Bytes
/
mfwApc.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
/**
* APC accessor for user cahce.
*/
class mfwApc {
static $default_expire = 0; ///< 無期限
protected static function makeKey($key)
{
return mfwServerEnv::cachePrefix().$key;
}
public static function defaultExpire($expire=null)
{
if(!is_null($expire)){
self::$default_expire = (int)$expire;
}
return self::$default_expire;
}
public static function set($key, $value, $expire=null)
{
if(is_null($expire)){
$expire = self::$default_expire;
}
return apc_store(static::makeKey($key),$value,$expire);
}
public static function get($key)
{
return apc_fetch(static::makeKey($key));
}
public static function delete($key)
{
return apc_delete(static::makeKey($key));
}
public static function deletePrefixMatch($keyprefix)
{
$keyprefix = mfwServerEnv::cachePrefix().$keyprefix;
$keyprefix = preg_quote($keyprefix,'/');
$it = new APCIterator('user',"/^{$keyprefix}/",APC_ITER_KEY);
foreach($it as $i){
apc_delete($i['key']);
}
}
}