Changeset 59141 for trunk/src/wp-includes/SimplePie/src/Cache/Memcached.php
- Timestamp:
- 09/30/2024 10:48:16 PM (5 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/Memcached.php
r47733 r59141 1 1 <?php 2 2 3 /** 3 4 * SimplePie … … 6 7 * Takes the hard work out of managing a complete RSS/Atom solution. 7 8 * 8 * Copyright (c) 2004-20 16, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors9 * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 10 * All rights reserved. 10 11 * … … 42 43 */ 43 44 45 namespace SimplePie\Cache; 46 47 use Memcached as NativeMemcached; 48 44 49 /** 45 50 * Caches data to memcached … … 55 60 * @author Paul L. McNeely 56 61 * @uses Memcached 62 * @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead 57 63 */ 58 class SimplePie_Cache_Memcached implements SimplePie_Cache_Base64 class Memcached implements Base 59 65 { 60 66 /** 61 * Memcached instance62 * @var Memcached67 * NativeMemcached instance 68 * @var NativeMemcached 63 69 */ 64 70 protected $cache; … … 79 85 * Create a new cache object 80 86 * @param string $location Location string (from SimplePie::$cache_location) 81 * @param string $name 82 * @param string $typeEither TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data87 * @param string $name Unique ID for the cache 88 * @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data 83 89 */ 84 public function __construct($location, $name, $type) { 85 $this->options = array( 90 public function __construct($location, $name, $type) 91 { 92 $this->options = [ 86 93 'host' => '127.0.0.1', 87 94 'port' => 11211, 88 'extras' => array(95 'extras' => [ 89 96 'timeout' => 3600, // one hour 90 97 'prefix' => 'simplepie_', 91 ),92 );93 $this->options = SimplePie_Misc::array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location));98 ], 99 ]; 100 $this->options = array_replace_recursive($this->options, \SimplePie\Cache::parse_URL($location)); 94 101 95 102 $this->name = $this->options['extras']['prefix'] . md5("$name:$type"); 96 103 97 $this->cache = new Memcached();104 $this->cache = new NativeMemcached(); 98 105 $this->cache->addServer($this->options['host'], (int)$this->options['port']); 99 106 } … … 101 108 /** 102 109 * Save data to the cache 103 * @param array| SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property110 * @param array|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property 104 111 * @return bool Successfulness 105 112 */ 106 public function save($data) { 107 if ($data instanceof SimplePie) { 113 public function save($data) 114 { 115 if ($data instanceof \SimplePie\SimplePie) { 108 116 $data = $data->data; 109 117 } … … 116 124 * @return array Data for SimplePie::$data 117 125 */ 118 public function load() { 126 public function load() 127 { 119 128 $data = $this->cache->get($this->name); 120 129 … … 129 138 * @return int Timestamp 130 139 */ 131 public function mtime() { 140 public function mtime() 141 { 132 142 $data = $this->cache->get($this->name . '_mtime'); 133 143 return (int) $data; … … 138 148 * @return bool Success status 139 149 */ 140 public function touch() { 150 public function touch() 151 { 141 152 $data = $this->cache->get($this->name); 142 153 return $this->setData($data); … … 147 158 * @return bool Success status 148 159 */ 149 public function unlink() { 160 public function unlink() 161 { 150 162 return $this->cache->delete($this->name, 0); 151 163 } 152 164 153 165 /** 154 * Set the last modified time and data to Memcached166 * Set the last modified time and data to NativeMemcached 155 167 * @return bool Success status 156 168 */ 157 private function setData($data) {158 169 private function setData($data) 170 { 159 171 if ($data !== false) { 160 172 $this->cache->set($this->name . '_mtime', time(), (int)$this->options['extras']['timeout']); … … 165 177 } 166 178 } 179 180 class_alias('SimplePie\Cache\Memcached', 'SimplePie_Cache_Memcached');
Note: See TracChangeset
for help on using the changeset viewer.