[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Joomla! Content Management System 4 * 5 * @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org> 6 * @license GNU General Public License version 2 or later; see LICENSE.txt 7 */ 8 9 namespace Joomla\CMS\Cache\Storage; 10 11 \defined('JPATH_PLATFORM') or die; 12 13 use Joomla\CMS\Cache\CacheStorage; 14 15 /** 16 * WinCache cache storage handler 17 * 18 * @link https://www.php.net/manual/en/book.wincache.php 19 * @since 1.7.0 20 * @deprecated 5.0 WinCache is abandoned and not supported from PHP 8 onwards 21 */ 22 class WincacheStorage extends CacheStorage 23 { 24 /** 25 * Check if the cache contains data stored by ID and group 26 * 27 * @param string $id The cache data ID 28 * @param string $group The cache data group 29 * 30 * @return boolean 31 * 32 * @since 3.7.0 33 * @deprecated 5.0 34 */ 35 public function contains($id, $group) 36 { 37 return wincache_ucache_exists($this->_getCacheId($id, $group)); 38 } 39 40 /** 41 * Get cached data by ID and group 42 * 43 * @param string $id The cache data ID 44 * @param string $group The cache data group 45 * @param boolean $checkTime True to verify cache time expiration threshold 46 * 47 * @return mixed Boolean false on failure or a cached data object 48 * 49 * @since 1.7.0 50 * @deprecated 5.0 51 */ 52 public function get($id, $group, $checkTime = true) 53 { 54 return wincache_ucache_get($this->_getCacheId($id, $group)); 55 } 56 57 /** 58 * Get all cached data 59 * 60 * @return mixed Boolean false on failure or a cached data object 61 * 62 * @since 1.7.0 63 * @deprecated 5.0 64 */ 65 public function getAll() 66 { 67 $allinfo = wincache_ucache_info(); 68 $keys = $allinfo['ucache_entries']; 69 $secret = $this->_hash; 70 $data = array(); 71 72 foreach ($keys as $key) 73 { 74 $name = $key['key_name']; 75 $namearr = explode('-', $name); 76 77 if ($namearr !== false && $namearr[0] == $secret && $namearr[1] === 'cache') 78 { 79 $group = $namearr[2]; 80 81 if (!isset($data[$group])) 82 { 83 $item = new CacheStorageHelper($group); 84 } 85 else 86 { 87 $item = $data[$group]; 88 } 89 90 if (isset($key['value_size'])) 91 { 92 $item->updateSize($key['value_size']); 93 } 94 else 95 { 96 // Dummy, WINCACHE version is too low. 97 $item->updateSize(1); 98 } 99 100 $data[$group] = $item; 101 } 102 } 103 104 return $data; 105 } 106 107 /** 108 * Store the data to cache by ID and group 109 * 110 * @param string $id The cache data ID 111 * @param string $group The cache data group 112 * @param string $data The data to store in cache 113 * 114 * @return boolean 115 * 116 * @since 1.7.0 117 * @deprecated 5.0 118 */ 119 public function store($id, $group, $data) 120 { 121 return wincache_ucache_set($this->_getCacheId($id, $group), $data, $this->_lifetime); 122 } 123 124 /** 125 * Remove a cached data entry by ID and group 126 * 127 * @param string $id The cache data ID 128 * @param string $group The cache data group 129 * 130 * @return boolean 131 * 132 * @since 1.7.0 133 * @deprecated 5.0 134 */ 135 public function remove($id, $group) 136 { 137 return wincache_ucache_delete($this->_getCacheId($id, $group)); 138 } 139 140 /** 141 * Clean cache for a group given a mode. 142 * 143 * group mode : cleans all cache in the group 144 * notgroup mode : cleans all cache not in the group 145 * 146 * @param string $group The cache data group 147 * @param string $mode The mode for cleaning cache [group|notgroup] 148 * 149 * @return boolean 150 * 151 * @since 1.7.0 152 * @deprecated 5.0 153 */ 154 public function clean($group, $mode = null) 155 { 156 $allinfo = wincache_ucache_info(); 157 $keys = $allinfo['ucache_entries']; 158 $secret = $this->_hash; 159 160 foreach ($keys as $key) 161 { 162 if (strpos($key['key_name'], $secret . '-cache-' . $group . '-') === 0 xor $mode !== 'group') 163 { 164 wincache_ucache_delete($key['key_name']); 165 } 166 } 167 168 return true; 169 } 170 171 /** 172 * Garbage collect expired cache data 173 * 174 * @return boolean 175 * 176 * @since 1.7.0 177 * @deprecated 5.0 178 */ 179 public function gc() 180 { 181 $allinfo = wincache_ucache_info(); 182 $keys = $allinfo['ucache_entries']; 183 $secret = $this->_hash; 184 185 foreach ($keys as $key) 186 { 187 if (strpos($key['key_name'], $secret . '-cache-')) 188 { 189 wincache_ucache_get($key['key_name']); 190 } 191 } 192 193 return true; 194 } 195 196 /** 197 * Test to see if the storage handler is available. 198 * 199 * @return boolean 200 * 201 * @since 3.0.0 202 * @deprecated 5.0 203 */ 204 public static function isSupported() 205 { 206 return \extension_loaded('wincache') && \function_exists('wincache_ucache_get') && !strcmp(ini_get('wincache.ucenabled'), '1'); 207 } 208 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |