1+ <?php namespace Illuminate \Cache ;
2+
3+ class XCacheStore implements StoreInterface {
4+
5+ /**
6+ * A string that should be prepended to keys.
7+ *
8+ * @var string
9+ */
10+ protected $ prefix ;
11+
12+ /**
13+ * Create a new WinCache store.
14+ *
15+ * @param string $prefix
16+ * @return void
17+ */
18+ public function __construct ($ prefix = '' )
19+ {
20+ $ this ->prefix = $ prefix ;
21+ }
22+
23+ /**
24+ * Retrieve an item from the cache by key.
25+ *
26+ * @param string $key
27+ * @return mixed
28+ */
29+ public function get ($ key )
30+ {
31+ $ value = xcache_get ($ this ->prefix .$ key );
32+
33+ if (isset ($ value ))
34+ {
35+ return $ value ;
36+ }
37+ }
38+
39+ /**
40+ * Store an item in the cache for a given number of minutes.
41+ *
42+ * @param string $key
43+ * @param mixed $value
44+ * @param int $minutes
45+ * @return void
46+ */
47+ public function put ($ key , $ value , $ minutes )
48+ {
49+ xcache_set ($ this ->prefix .$ key , $ value , $ minutes * 60 );
50+ }
51+
52+ /**
53+ * Increment the value of an item in the cache.
54+ *
55+ * @param string $key
56+ * @param mixed $value
57+ * @return void
58+ */
59+ public function increment ($ key , $ value = 1 )
60+ {
61+ return xcache_inc ($ this ->prefix .$ key , $ value );
62+ }
63+
64+ /**
65+ * Increment the value of an item in the cache.
66+ *
67+ * @param string $key
68+ * @param mixed $value
69+ * @return void
70+ */
71+ public function decrement ($ key , $ value = 1 )
72+ {
73+ return xcache_dec ($ this ->prefix .$ key , $ value );
74+ }
75+
76+ /**
77+ * Store an item in the cache indefinitely.
78+ *
79+ * @param string $key
80+ * @param mixed $value
81+ * @return void
82+ */
83+ public function forever ($ key , $ value )
84+ {
85+ return $ this ->put ($ key , $ value , 0 );
86+ }
87+
88+ /**
89+ * Remove an item from the cache.
90+ *
91+ * @param string $key
92+ * @return void
93+ */
94+ public function forget ($ key )
95+ {
96+ xcache_unset ($ this ->prefix .$ key );
97+ }
98+
99+ /**
100+ * Remove all items from the cache.
101+ *
102+ * @return void
103+ */
104+ public function flush ()
105+ {
106+ xcache_clear_cache (XC_TYPE_VAR );
107+ }
108+
109+ /**
110+ * Begin executing a new section operation.
111+ *
112+ * @param string $name
113+ * @return \Illuminate\Cache\Section
114+ */
115+ public function section ($ name )
116+ {
117+ return new Section ($ this , $ name );
118+ }
119+
120+ /**
121+ * Get the cache key prefix.
122+ *
123+ * @return string
124+ */
125+ public function getPrefix ()
126+ {
127+ return $ this ->prefix ;
128+ }
129+
130+ }
0 commit comments