Mercurial > hg > cmmr2012-drupal-site
comparison vendor/doctrine/cache/lib/Doctrine/Common/Cache/WinCacheCache.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 <?php | |
2 /* | |
3 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
4 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
5 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
6 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
7 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
8 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
9 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
10 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
11 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
12 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
13 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
14 * | |
15 * This software consists of voluntary contributions made by many individuals | |
16 * and is licensed under the MIT license. For more information, see | |
17 * <http://www.doctrine-project.org>. | |
18 */ | |
19 | |
20 namespace Doctrine\Common\Cache; | |
21 | |
22 /** | |
23 * WinCache cache provider. | |
24 * | |
25 * @link www.doctrine-project.org | |
26 * @since 2.2 | |
27 * @author Benjamin Eberlei <kontakt@beberlei.de> | |
28 * @author Guilherme Blanco <guilhermeblanco@hotmail.com> | |
29 * @author Jonathan Wage <jonwage@gmail.com> | |
30 * @author Roman Borschel <roman@code-factory.org> | |
31 * @author David Abdemoulaie <dave@hobodave.com> | |
32 */ | |
33 class WinCacheCache extends CacheProvider | |
34 { | |
35 /** | |
36 * {@inheritdoc} | |
37 */ | |
38 protected function doFetch($id) | |
39 { | |
40 return wincache_ucache_get($id); | |
41 } | |
42 | |
43 /** | |
44 * {@inheritdoc} | |
45 */ | |
46 protected function doContains($id) | |
47 { | |
48 return wincache_ucache_exists($id); | |
49 } | |
50 | |
51 /** | |
52 * {@inheritdoc} | |
53 */ | |
54 protected function doSave($id, $data, $lifeTime = 0) | |
55 { | |
56 return wincache_ucache_set($id, $data, $lifeTime); | |
57 } | |
58 | |
59 /** | |
60 * {@inheritdoc} | |
61 */ | |
62 protected function doDelete($id) | |
63 { | |
64 return wincache_ucache_delete($id); | |
65 } | |
66 | |
67 /** | |
68 * {@inheritdoc} | |
69 */ | |
70 protected function doFlush() | |
71 { | |
72 return wincache_ucache_clear(); | |
73 } | |
74 | |
75 /** | |
76 * {@inheritdoc} | |
77 */ | |
78 protected function doFetchMultiple(array $keys) | |
79 { | |
80 return wincache_ucache_get($keys); | |
81 } | |
82 | |
83 /** | |
84 * {@inheritdoc} | |
85 */ | |
86 protected function doSaveMultiple(array $keysAndValues, $lifetime = 0) | |
87 { | |
88 $result = wincache_ucache_set($keysAndValues, null, $lifetime); | |
89 | |
90 return empty($result); | |
91 } | |
92 | |
93 /** | |
94 * {@inheritdoc} | |
95 */ | |
96 protected function doGetStats() | |
97 { | |
98 $info = wincache_ucache_info(); | |
99 $meminfo = wincache_ucache_meminfo(); | |
100 | |
101 return array( | |
102 Cache::STATS_HITS => $info['total_hit_count'], | |
103 Cache::STATS_MISSES => $info['total_miss_count'], | |
104 Cache::STATS_UPTIME => $info['total_cache_uptime'], | |
105 Cache::STATS_MEMORY_USAGE => $meminfo['memory_total'], | |
106 Cache::STATS_MEMORY_AVAILABLE => $meminfo['memory_free'], | |
107 ); | |
108 } | |
109 } |