Changeset 59141 for trunk/src/wp-includes/SimplePie/src/Cache/Redis.php
- Timestamp:
- 09/30/2024 10:48:16 PM (4 months ago)
- Location:
- trunk/src/wp-includes/SimplePie/src
- Files:
-
- 1 added
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/SimplePie/src/Cache/Redis.php
r52393 r59141 2 2 3 3 /** 4 * SimplePie Redis Cache Extension 4 * SimplePie 5 * 6 * A PHP-Based RSS and Atom Feed Framework. 7 * Takes the hard work out of managing a complete RSS/Atom solution. 8 * 9 * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 10 * All rights reserved. 11 * 12 * Redistribution and use in source and binary forms, with or without modification, are 13 * permitted provided that the following conditions are met: 14 * 15 * * Redistributions of source code must retain the above copyright notice, this list of 16 * conditions and the following disclaimer. 17 * 18 * * Redistributions in binary form must reproduce the above copyright notice, this list 19 * of conditions and the following disclaimer in the documentation and/or other materials 20 * provided with the distribution. 21 * 22 * * Neither the name of the SimplePie Team nor the names of its contributors may be used 23 * to endorse or promote products derived from this software without specific prior 24 * written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS 27 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 28 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS 29 * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 33 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 * POSSIBILITY OF SUCH DAMAGE. 5 35 * 6 36 * @package SimplePie 7 * @author Jan Kozak <galvani78@gmail.com> 8 * @link http://galvani.cz/ 37 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 * @author Ryan Parman 39 * @author Sam Sneddon 40 * @author Ryan McCue 41 * @link http://simplepie.org/ SimplePie 9 42 * @license http://www.opensource.org/licenses/bsd-license.php BSD License 10 * @version 0.2.911 43 */ 12 44 45 namespace SimplePie\Cache; 46 47 use Redis as NativeRedis; 13 48 14 49 /** … … 24 59 * @subpackage Caching 25 60 * @uses Redis 61 * @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead 26 62 */ 27 class SimplePie_Cache_Redis implements SimplePie_Cache_Base { 63 class Redis implements Base 64 { 28 65 /** 29 66 * Redis instance 30 67 * 31 * @var \Redis68 * @var NativeRedis 32 69 */ 33 70 protected $cache; … … 46 83 */ 47 84 protected $name; 48 49 /**50 * Cache Data51 *52 * @var type53 */54 protected $data;55 85 56 86 /** … … 59 89 * @param string $location Location string (from SimplePie::$cache_location) 60 90 * @param string $name Unique ID for the cache 61 * @param string $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data 62 */ 63 public function __construct($location, $name, $options = null) { 91 * @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data 92 */ 93 public function __construct($location, $name, $options = null) 94 { 64 95 //$this->cache = \flow\simple\cache\Redis::getRedisClientInstance(); 65 $parsed = SimplePie_Cache::parse_URL($location);66 $redis = new Redis();96 $parsed = \SimplePie\Cache::parse_URL($location); 97 $redis = new NativeRedis(); 67 98 $redis->connect($parsed['host'], $parsed['port']); 68 99 if (isset($parsed['pass'])) { … … 77 108 $this->options = $options; 78 109 } else { 79 $this->options = array (110 $this->options = [ 80 111 'prefix' => 'rss:simple_primary:', 81 112 'expire' => 0, 82 );113 ]; 83 114 } 84 115 … … 87 118 88 119 /** 89 * @param \Redis $cache 90 */ 91 public function setRedisClient(\Redis $cache) { 120 * @param NativeRedis $cache 121 */ 122 public function setRedisClient(NativeRedis $cache) 123 { 92 124 $this->cache = $cache; 93 125 } … … 96 128 * Save data to the cache 97 129 * 98 * @param array| SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property130 * @param array|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property 99 131 * @return bool Successfulness 100 132 */ 101 public function save($data) { 102 if ($data instanceof SimplePie) { 133 public function save($data) 134 { 135 if ($data instanceof \SimplePie\SimplePie) { 103 136 $data = $data->data; 104 137 } … … 116 149 * @return array Data for SimplePie::$data 117 150 */ 118 public function load() { 151 public function load() 152 { 119 153 $data = $this->cache->get($this->name); 120 154 … … 130 164 * @return int Timestamp 131 165 */ 132 public function mtime() {133 166 public function mtime() 167 { 134 168 $data = $this->cache->get($this->name); 135 169 … … 146 180 * @return bool Success status 147 181 */ 148 public function touch() {149 182 public function touch() 183 { 150 184 $data = $this->cache->get($this->name); 151 185 … … 166 200 * @return bool Success status 167 201 */ 168 public function unlink() { 202 public function unlink() 203 { 169 204 return $this->cache->set($this->name, null); 170 205 } 171 172 206 } 207 208 class_alias('SimplePie\Cache\Redis', 'SimplePie_Cache_Redis');
Note: See TracChangeset
for help on using the changeset viewer.