4
4
5
5
class ApcWrapper
6
6
{
7
- /**
8
- * Indicates if APCu is supported.
9
- *
10
- * @var bool
11
- */
12
- protected $ apcu = false ;
13
-
14
- /**
15
- * Create a new APC wrapper instance.
16
- *
17
- * @return void
18
- */
19
- public function __construct ()
20
- {
21
- $ this ->apcu = function_exists ('apcu_fetch ' );
22
- }
23
-
24
7
/**
25
8
* Get an item from the cache.
26
9
*
@@ -29,7 +12,7 @@ public function __construct()
29
12
*/
30
13
public function get ($ key )
31
14
{
32
- $ fetchedValue = $ this -> apcu ? apcu_fetch ( $ key , $ success ) : apc_fetch ($ key , $ success );
15
+ $ fetchedValue = apcu_fetch ($ key , $ success );
33
16
34
17
return $ success ? $ fetchedValue : null ;
35
18
}
@@ -44,7 +27,7 @@ public function get($key)
44
27
*/
45
28
public function put ($ key , $ value , $ seconds )
46
29
{
47
- return $ this -> apcu ? apcu_store ( $ key , $ value , $ seconds ) : apc_store ($ key , $ value , $ seconds );
30
+ return apcu_store ($ key , $ value , $ seconds );
48
31
}
49
32
50
33
/**
@@ -56,7 +39,7 @@ public function put($key, $value, $seconds)
56
39
*/
57
40
public function increment ($ key , $ value )
58
41
{
59
- return $ this -> apcu ? apcu_inc ( $ key , $ value ) : apc_inc ($ key , $ value );
42
+ return apcu_inc ($ key , $ value );
60
43
}
61
44
62
45
/**
@@ -68,7 +51,7 @@ public function increment($key, $value)
68
51
*/
69
52
public function decrement ($ key , $ value )
70
53
{
71
- return $ this -> apcu ? apcu_dec ( $ key , $ value ) : apc_dec ($ key , $ value );
54
+ return apcu_dec ($ key , $ value );
72
55
}
73
56
74
57
/**
@@ -79,7 +62,7 @@ public function decrement($key, $value)
79
62
*/
80
63
public function delete ($ key )
81
64
{
82
- return $ this -> apcu ? apcu_delete ( $ key ) : apc_delete ($ key );
65
+ return apcu_delete ($ key );
83
66
}
84
67
85
68
/**
@@ -89,6 +72,6 @@ public function delete($key)
89
72
*/
90
73
public function flush ()
91
74
{
92
- return $ this -> apcu ? apcu_clear_cache () : apc_clear_cache ( ' user ' );
75
+ return apcu_clear_cache ();
93
76
}
94
77
}
0 commit comments