~horux-dev/horux-webcli/thfo

« back to all changes in this revision

Viewing changes to yii/framework/caching/CWinCache.php

  • Committer: Thierry Forchelet
  • Date: 2011-02-25 13:30:15 UTC
  • Revision ID: thierry.forchelet@letux.ch-20110225133015-zxyj9w7sqv8ly971
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * CWinCache class file
 
4
 *
 
5
 * @author Alexander Makarov <sam@rmcreative.ru>
 
6
 * @link http://www.yiiframework.com/
 
7
 * @copyright Copyright &copy; 2008-2011 Yii Software LLC
 
8
 * @license http://www.yiiframework.com/license/
 
9
 */
 
10
 
 
11
/**
 
12
 * CWinCache implements a cache application component based on {@link http://www.iis.net/expand/wincacheforphp WinCache}.
 
13
 *
 
14
 * To use this application component, the WinCache PHP extension must be loaded.
 
15
 *
 
16
 * See {@link CCache} manual for common cache operations that are supported by CWinCache.
 
17
 *
 
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
 
21
 * @since 1.1.2
 
22
 */
 
23
class CWinCache extends CCache {
 
24
        /**
 
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
 
29
         */
 
30
        public function init()
 
31
        {
 
32
                parent::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.'));
 
37
        }
 
38
 
 
39
        /**
 
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.
 
44
         */
 
45
        protected function getValue($key)
 
46
        {
 
47
                return wincache_ucache_get($key);
 
48
        }
 
49
 
 
50
        /**
 
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     
 
54
         */
 
55
        protected function getValues($keys)
 
56
        {
 
57
                return wincache_ucache_get($keys);
 
58
        }
 
59
 
 
60
        /**
 
61
         * Stores a value identified by a key in cache.
 
62
         * This is the implementation of the method declared in the parent class.
 
63
         *
 
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
 
68
         */
 
69
        protected function setValue($key,$value,$expire)
 
70
        {
 
71
                return wincache_ucache_set($key,$value,$expire);
 
72
        }
 
73
 
 
74
        /**
 
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.
 
77
         *
 
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
 
82
         */
 
83
        protected function addValue($key,$value,$expire)
 
84
        {
 
85
                return wincache_ucache_add($key,$value,$expire);
 
86
        }
 
87
 
 
88
        /**
 
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
 
93
         */
 
94
        protected function deleteValue($key)
 
95
        {
 
96
                return wincache_ucache_delete($key);
 
97
        }
 
98
 
 
99
        /**
 
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.
 
103
         * @since 1.1.5
 
104
         */
 
105
        protected function flushValues()
 
106
        {
 
107
                return wincache_ucache_clear();
 
108
        }
 
109
}
 
 
b'\\ No newline at end of file'