5
* @author Alexander Makarov <sam@rmcreative.ru>
6
* @link http://www.yiiframework.com/
7
* @copyright Copyright © 2008-2011 Yii Software LLC
8
* @license http://www.yiiframework.com/license/
12
* CWinCache implements a cache application component based on {@link http://www.iis.net/expand/wincacheforphp WinCache}.
14
* To use this application component, the WinCache PHP extension must be loaded.
16
* See {@link CCache} manual for common cache operations that are supported by CWinCache.
18
* @author Alexander Makarov <sam@rmcreative.ru>
19
* @version $Id: CWinCache.php 2799 2011-01-01 19:31:13Z qiang.xue $
20
* @package system.caching
23
class CWinCache extends CCache {
25
* Initializes this application component.
26
* This method is required by the {@link IApplicationComponent} interface.
27
* It checks the availability of WinCache extension and WinCache user cache.
28
* @throws CException if WinCache extension is not loaded or user cache is disabled
30
public function init()
33
if(!extension_loaded('wincache'))
34
throw new CException(Yii::t('yii', 'CWinCache requires PHP wincache extension to be loaded.'));
35
if(!ini_get('wincache.ucenabled'))
36
throw new CException(Yii::t('yii', 'CWinCache user cache is disabled. Please set wincache.ucenabled to On in your php.ini.'));
40
* Retrieves a value from cache with a specified key.
41
* This is the implementation of the method declared in the parent class.
42
* @param string $key a unique key identifying the cached value
43
* @return string the value stored in cache, false if the value is not in the cache or expired.
45
protected function getValue($key)
47
return wincache_ucache_get($key);
51
* Retrieves multiple values from cache with the specified keys.
52
* @param array $keys a list of keys identifying the cached values
53
* @return array a list of cached values indexed by the keys
55
protected function getValues($keys)
57
return wincache_ucache_get($keys);
61
* Stores a value identified by a key in cache.
62
* This is the implementation of the method declared in the parent class.
64
* @param string $key the key identifying the value to be cached
65
* @param string $value the value to be cached
66
* @param integer $expire the number of seconds in which the cached value will expire. 0 means never expire.
67
* @return boolean true if the value is successfully stored into cache, false otherwise
69
protected function setValue($key,$value,$expire)
71
return wincache_ucache_set($key,$value,$expire);
75
* Stores a value identified by a key into cache if the cache does not contain this key.
76
* This is the implementation of the method declared in the parent class.
78
* @param string $key the key identifying the value to be cached
79
* @param string $value the value to be cached
80
* @param integer $expire the number of seconds in which the cached value will expire. 0 means never expire.
81
* @return boolean true if the value is successfully stored into cache, false otherwise
83
protected function addValue($key,$value,$expire)
85
return wincache_ucache_add($key,$value,$expire);
89
* Deletes a value with the specified key from cache
90
* This is the implementation of the method declared in the parent class.
91
* @param string $key the key of the value to be deleted
92
* @return boolean if no error happens during deletion
94
protected function deleteValue($key)
96
return wincache_ucache_delete($key);
100
* Deletes all values from cache.
101
* This is the implementation of the method declared in the parent class.
102
* @return boolean whether the flush operation was successful.
105
protected function flushValues()
107
return wincache_ucache_clear();
b'\\ No newline at end of file'