1: <?php namespace Laravel\Cache\Drivers;
2:
3: class WinCache extends Driver {
4:
5: /**
6: * The cache key from the cache configuration file.
7: *
8: * @var string
9: */
10: protected $key;
11:
12: /**
13: * Create a new WinCache cache driver instance.
14: *
15: * @param string $key
16: * @return void
17: */
18: public function __construct($key)
19: {
20: $this->key = $key;
21: }
22:
23: /**
24: * Determine if an item exists in the cache.
25: *
26: * @param string $key
27: * @return bool
28: */
29: public function has($key)
30: {
31: return ( ! is_null($this->get($key)));
32: }
33:
34: /**
35: * Retrieve an item from the cache driver.
36: *
37: * @param string $key
38: * @return mixed
39: */
40: protected function retrieve($key)
41: {
42: if (($cache = wincache_ucache_get($this->key.$key)) !== false)
43: {
44: return $cache;
45: }
46: }
47:
48: /**
49: * Write an item to the cache for a given number of minutes.
50: *
51: * <code>
52: * // Put an item in the cache for 15 minutes
53: * Cache::put('name', 'Taylor', 15);
54: * </code>
55: *
56: * @param string $key
57: * @param mixed $value
58: * @param int $minutes
59: * @return void
60: */
61: public function put($key, $value, $minutes)
62: {
63: wincache_ucache_add($this->key.$key, $value, $minutes * 60);
64: }
65:
66: /**
67: * Write an item to the cache that lasts forever.
68: *
69: * @param string $key
70: * @param mixed $value
71: * @return void
72: */
73: public function forever($key, $value)
74: {
75: return $this->put($key, $value, 0);
76: }
77:
78: /**
79: * Delete an item from the cache.
80: *
81: * @param string $key
82: * @return void
83: */
84: public function forget($key)
85: {
86: wincache_ucache_delete($this->key.$key);
87: }
88:
89: }