Changeset 47121
- Timestamp:
- 01/29/2020 12:36:17 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/object-cache.php
r46586 r47121 6 6 * returns false. 7 7 * 8 * @link http ://www.php.net/manual/en/memcached.add.php9 * 10 * @param string 11 * @param mixed 12 * @param string 13 * @param int 14 * @return bool Returns TRUE on success or FALSEon failure.8 * @link https://www.php.net/manual/en/memcached.add.php 9 * 10 * @param string $key The key under which to store the value. 11 * @param mixed $value The value to store. 12 * @param string $group The group value appended to the $key. 13 * @param int $expiration The expiration time, defaults to 0. 14 * @return bool True on success, false on failure. 15 15 */ 16 16 function wp_cache_add( $key, $value, $group = '', $expiration = 0 ) { … … 27 27 * specified server_key. 28 28 * 29 * @link http ://www.php.net/manual/en/memcached.addbykey.php30 * 31 * @param string $server_keyThe key identifying the server to store the value on.32 * @param string $keyThe key under which to store the value.33 * @param mixed $valueThe value to store.34 * @param string $groupThe group value appended to the $key.35 * @param int $expirationThe expiration time, defaults to 0.36 * @return bool Returns TRUE on success or FALSEon failure.29 * @link https://www.php.net/manual/en/memcached.addbykey.php 30 * 31 * @param string $server_key The key identifying the server to store the value on. 32 * @param string $key The key under which to store the value. 33 * @param mixed $value The value to store. 34 * @param string $group The group value appended to the $key. 35 * @param int $expiration The expiration time, defaults to 0. 36 * @return bool True on success, false on failure. 37 37 */ 38 38 function wp_cache_add_by_key( $server_key, $key, $value, $group = '', $expiration = 0 ) { … … 42 42 43 43 /** 44 * Add a single server to the list of Memcached servers. 45 * 46 * @link http://www.php.net/manual/en/memcached.addserver.php 47 * 48 * @param string $host The hostname of the memcache server. 49 * @param int $port The port on which memcache is running. 50 * @param int $weight The weight of the server relative to the total weight of all the servers in the pool. 51 * @return bool Returns TRUE on success or FALSE on failure. 44 * Adds a single server to the list of Memcached servers. 45 * 46 * @link https://www.php.net/manual/en/memcached.addserver.php 47 * 48 * @param string $host The hostname of the memcache server. 49 * @param int $port The port on which memcache is running. 50 * @param int $weight The weight of the server relative to the total weight 51 * of all the servers in the pool. 52 * @return bool True on success, false on failure. 52 53 */ 53 54 function wp_cache_add_server( $host, $port, $weight = 0 ) { … … 62 63 * weight value: $servers = array( array( '127.0.0.1', 11211, 0 ) ); 63 64 * 64 * @link http ://www.php.net/manual/en/memcached.addservers.php65 * 66 * @param array $serversArray of server to register.67 * @return bool True on success;false on failure.65 * @link https://www.php.net/manual/en/memcached.addservers.php 66 * 67 * @param array $servers Array of server to register. 68 * @return bool True on success, false on failure. 68 69 */ 69 70 function wp_cache_add_servers( $servers ) { … … 73 74 74 75 /** 75 * Append data to an existing item.76 * 77 * This method should throw an error if it is used with compressed data. This78 * is an expected behavior. Memcached casts the value to be appended to the initial value to the79 * t ype of the initial value. Be careful as this leads to unexpected behavior at times. Due to80 * how memcached treats types, the behavior has been mimicked in the internal cache to produce81 * similar results and improve consistency. It is recommend that appends only occur with data of76 * Appends data to an existing item. 77 * 78 * This method should throw an error if it is used with compressed data. 79 * This is an expected behavior. Memcached casts the value to be appended to the initial value 80 * to the type of the initial value. Be careful as this leads to unexpected behavior at times. 81 * Due to how memcached treats types, the behavior has been mimicked in the internal cache to produce 82 * similar results and improve consistency. It is recommended that appends only occur with data of 82 83 * the same type. 83 84 * 84 * @link http ://www.php.net/manual/en/memcached.append.php85 * 86 * @param string $keyThe key under which to store the value.87 * @param mixed $value Must be string as appending mixed values is not well-defined88 * @param string $groupThe group value appended to the $key.89 * @return bool Returns TRUE on success or FALSEon failure.85 * @link https://www.php.net/manual/en/memcached.append.php 86 * 87 * @param string $key The key under which to store the value. 88 * @param mixed $value Must be string as appending mixed values is not well-defined. 89 * @param string $group The group value appended to the $key. 90 * @return bool True on success, false on failure. 90 91 */ 91 92 function wp_cache_append( $key, $value, $group = '' ) { … … 95 96 96 97 /** 97 * Append data to an existing item by server key.98 * 99 * This method should throw an error if it is used with compressed data. This100 * is an expected behavior. Memcached casts the value to be appended to the initial value to the101 * t ype of the initial value. Be careful as this leads to unexpected behavior at times. Due to102 * how memcached treats types, the behavior has been mimicked in the internal cache to produce103 * similar results and improve consistency. It is recommend that appends only occur with data of98 * Appends data to an existing item by server key. 99 * 100 * This method should throw an error if it is used with compressed data. 101 * This is an expected behavior. Memcached casts the value to be appended to the initial value 102 * to the type of the initial value. Be careful as this leads to unexpected behavior at times. 103 * Due to how memcached treats types, the behavior has been mimicked in the internal cache to produce 104 * similar results and improve consistency. It is recommended that appends only occur with data of 104 105 * the same type. 105 106 * 106 * @link http ://www.php.net/manual/en/memcached.appendbykey.php107 * 108 * @param string $server_keyThe key identifying the server to store the value on.109 * @param string $keyThe key under which to store the value.110 * @param mixed $value Must be string as appending mixed values is not well-defined111 * @param string $groupThe group value appended to the $key.112 * @return bool Returns TRUE on success or FALSEon failure.107 * @link https://www.php.net/manual/en/memcached.appendbykey.php 108 * 109 * @param string $server_key The key identifying the server to store the value on. 110 * @param string $key The key under which to store the value. 111 * @param mixed $value Must be string as appending mixed values is not well-defined. 112 * @param string $group The group value appended to the $key. 113 * @return bool True on success, false on failure. 113 114 */ 114 115 function wp_cache_append_by_key( $server_key, $key, $value, $group = '' ) { … … 120 121 * Performs a "check and set" to store data. 121 122 * 122 * The set will be successful only if the no other request has updated the value since it was fetched by123 * this request.124 * 125 * @link http ://www.php.net/manual/en/memcached.cas.php126 * 127 * @param float 128 * @param string 129 * @param mixed 130 * @param string 131 * @param int 132 * @return bool Returns TRUE on success or FALSEon failure.123 * The set will be successful only if the no other request has updated the value 124 * since it was fetched by this request. 125 * 126 * @link https://www.php.net/manual/en/memcached.cas.php 127 * 128 * @param float $cas_token Unique value associated with the existing item. Generated by memcached. 129 * @param string $key The key under which to store the value. 130 * @param mixed $value The value to store. 131 * @param string $group The group value appended to the $key. 132 * @param int $expiration The expiration time, defaults to 0. 133 * @return bool True on success, false on failure. 133 134 */ 134 135 function wp_cache_cas( $cas_token, $key, $value, $group = '', $expiration = 0 ) { … … 140 141 * Performs a "check and set" to store data with a server key. 141 142 * 142 * The set will be successful only if the no other request has updated the value since it was fetched by143 * this request.144 * 145 * @link http ://www.php.net/manual/en/memcached.casbykey.php146 * 147 * @param string 148 * @param float 149 * @param string 150 * @param mixed 151 * @param string 152 * @param int 153 * @return bool Returns TRUE on success or FALSEon failure.143 * The set will be successful only if the no other request has updated the value 144 * since it was fetched by this request. 145 * 146 * @link https://www.php.net/manual/en/memcached.casbykey.php 147 * 148 * @param string $server_key The key identifying the server to store the value on. 149 * @param float $cas_token Unique value associated with the existing item. Generated by memcached. 150 * @param string $key The key under which to store the value. 151 * @param mixed $value The value to store. 152 * @param string $group The group value appended to the $key. 153 * @param int $expiration The expiration time, defaults to 0. 154 * @return bool True on success, false on failure. 154 155 */ 155 156 function wp_cache_cas_by_key( $cas_token, $server_key, $key, $value, $group = '', $expiration = 0 ) { … … 161 162 * Closes the cache. 162 163 * 163 * This function has ceased to do anything since WordPress 2.5. The164 * functionality was removed along with the rest of the persistent cache. This165 * does not mean that plugins can't implement this function when they need to166 * make sure that the cache is cleaned up after WordPress no longer needs it.164 * This function has ceased to do anything since WordPress 2.5. 165 * The functionality was removed along with the rest of the persistent cache. 166 * This does not mean that plugins can't implement this function when they need 167 * to make sure that the cache is cleaned up after WordPress no longer needs it. 167 168 * 168 169 * @since 2.0.0 169 170 * 170 * @return bool Always returns True171 * @return bool Always returns true. 171 172 */ 172 173 function wp_cache_close() { … … 175 176 176 177 /** 177 * Decrement a numeric item's value.178 * 179 * @link http ://www.php.net/manual/en/memcached.decrement.php180 * 181 * @param string 182 * @param int 183 * @param string 184 * @return int|bool Returns item's new value on success or FALSEon failure.178 * Decrements a numeric item's value. 179 * 180 * @link https://www.php.net/manual/en/memcached.decrement.php 181 * 182 * @param string $key The key under which to store the value. 183 * @param int $offset The amount by which to decrement the item's value. 184 * @param string $group The group value appended to the $key. 185 * @return int|bool Item's new value on success, false on failure. 185 186 */ 186 187 function wp_cache_decrement( $key, $offset = 1, $group = '' ) { … … 190 191 191 192 /** 192 * Decrement a numeric item's value.193 * 194 * Same as wp_cache_decrement. Original WordPress caching backends use wp_cache_decr. I195 * want both spellings to work.196 * 197 * @link http ://www.php.net/manual/en/memcached.decrement.php198 * 199 * @param string 200 * @param int 201 * @param string 202 * @return int|bool Returns item's new value on success or FALSEon failure.193 * Decrements a numeric item's value. 194 * 195 * This is the same as wp_cache_decrement(), but kept for backward compatibility. 196 * The original WordPress caching backends use wp_cache_decr(). 197 * 198 * @link https://www.php.net/manual/en/memcached.decrement.php 199 * 200 * @param string $key The key under which to store the value. 201 * @param int $offset The amount by which to decrement the item's value. 202 * @param string $group The group value appended to the $key. 203 * @return int|bool Item's new value on success, false on failure. 203 204 */ 204 205 function wp_cache_decr( $key, $offset = 1, $group = '' ) { … … 207 208 208 209 /** 209 * Remove the item from the cache.210 * 211 * Remove an item from memcached with identified by $key after $time seconds. The212 * $time parameter allows an object to be queued for deletion without immediately213 * deleting. Between the time that it is queued and the time it's deleted, add,214 * replace, and get will fail, but set will succeed.215 * 216 * @link http ://www.php.net/manual/en/memcached.delete.php217 * 218 * @param string $keyThe key under which to store the value.219 * @param string $groupThe group value appended to the $key.220 * @param int $timeThe amount of time the server will wait to delete the item in seconds.221 * @return bool Returns TRUE on success or FALSEon failure.210 * Removes the item from the cache. 211 * 212 * Removes an item from memcached with identified by $key after $time seconds. 213 * The $time parameter allows an object to be queued for deletion without 214 * immediately deleting. Between the time that it is queued and the time it's deleted, 215 * add, replace, and get will fail, but set will succeed. 216 * 217 * @link https://www.php.net/manual/en/memcached.delete.php 218 * 219 * @param string $key The key under which to store the value. 220 * @param string $group The group value appended to the $key. 221 * @param int $time The amount of time the server will wait to delete the item in seconds. 222 * @return bool True on success, false on failure. 222 223 */ 223 224 function wp_cache_delete( $key, $group = '', $time = 0 ) { … … 227 228 228 229 /** 229 * Remove the item from the cache by server key.230 * 231 * Remove an item from memcached with identified by $key after $time seconds. The232 * $time parameter allows an object to be queued for deletion without immediately233 * deleting. Between the time that it is queued and the time it's deleted, add,234 * replace, and get will fail, but set will succeed.235 * 236 * @link http ://www.php.net/manual/en/memcached.deletebykey.php237 * 238 * @param string 239 * @param string 240 * @param string 241 * @param int 242 * @return bool Returns TRUE on success or FALSEon failure.230 * Removes the item from the cache by server key. 231 * 232 * Removes an item from memcached with identified by $key after $time seconds. 233 * The $time parameter allows an object to be queued for deletion without 234 * immediately deleting. Between the time that it is queued and the time it's deleted, 235 * add, replace, and get will fail, but set will succeed. 236 * 237 * @link https://www.php.net/manual/en/memcached.deletebykey.php 238 * 239 * @param string $server_key The key identifying the server to store the value on. 240 * @param string $key The key under which to store the value. 241 * @param string $group The group value appended to the $key. 242 * @param int $time The amount of time the server will wait to delete the item in seconds. 243 * @return bool True on success, false on failure. 243 244 */ 244 245 function wp_cache_delete_by_key( $server_key, $key, $group = '', $time = 0 ) { … … 248 249 249 250 /** 250 * Fetch the next result.251 * 252 * @link http ://www.php.net/manual/en/memcached.fetch.php253 * 254 * @return array|bool Returns the next result or FALSE otherwise.251 * Fetches the next result. 252 * 253 * @link https://www.php.net/manual/en/memcached.fetch.php 254 * 255 * @return array|false The next result on success, false on failure. 255 256 */ 256 257 function wp_cache_fetch() { … … 260 261 261 262 /** 262 * Fetch all remaining results from the last request.263 * 264 * @link http ://www.php.net/manual/en/memcached.fetchall.php265 * 266 * @return array|bool Returns the results or FALSEon failure.263 * Fetches all remaining results from the last request. 264 * 265 * @link https://www.php.net/manual/en/memcached.fetchall.php 266 * 267 * @return array|false The results on success, false on failure. 267 268 */ 268 269 function wp_cache_fetch_all() { … … 272 273 273 274 /** 274 * Invalidate all items in the cache.275 * 276 * @link http ://www.php.net/manual/en/memcached.flush.php277 * 278 * @param int $delayNumber of seconds to wait before invalidating the items.279 * @return bool Returns TRUE on success or FALSEon failure.275 * Invalidates all items in the cache. 276 * 277 * @link https://www.php.net/manual/en/memcached.flush.php 278 * 279 * @param int $delay Number of seconds to wait before invalidating the items. 280 * @return bool True on success, false on failure. 280 281 */ 281 282 function wp_cache_flush( $delay = 0 ) { … … 285 286 286 287 /** 287 * Retrieve object from cache. 288 * 289 * Gets an object from cache based on $key and $group. In order to fully support the $cache_cb and $cas_token 290 * parameters, the runtime cache is ignored by this function if either of those values are set. If either of 291 * those values are set, the request is made directly to the memcached server for proper handling of the 292 * callback and/or token. 293 * 294 * Note that the $deprecated and $found args are only here for compatibility with the native wp_cache_get function. 295 * 296 * @link http://www.php.net/manual/en/memcached.get.php 297 * 298 * @param string $key The key under which to store the value. 299 * @param string $group The group value appended to the $key. 300 * @param bool $force Whether or not to force a cache invalidation. 301 * @param null|bool $found Variable passed by reference to determine if the value was found or not. 302 * @param null|string $cache_cb Read-through caching callback. 303 * @param null|float $cas_token The variable to store the CAS token in. 304 * @return bool|mixed Cached object value. 288 * Retrieves object from cache. 289 * 290 * Gets an object from cache based on $key and $group. In order to fully support 291 * the $cache_cb and $cas_token parameters, the runtime cache is ignored by this function 292 * if either of those values are set. In that case, the request is made directly 293 * to the memcached server for proper handling of the callback and/or token. 294 * 295 * Note that the $deprecated and $found args are only here for compatibility 296 * with the native wp_cache_get() function. 297 * 298 * @link https://www.php.net/manual/en/memcached.get.php 299 * 300 * @param string $key The key under which to store the value. 301 * @param string $group The group value appended to the $key. 302 * @param bool $force Whether or not to force a cache invalidation. 303 * @param null|bool $found Variable passed by reference to determine if the value was found or not. 304 * @param null|string $cache_cb Read-through caching callback. 305 * @param null|float $cas_token The variable to store the CAS token in. 306 * @return bool|mixed Cached object value. 305 307 */ 306 308 function wp_cache_get( $key, $group = '', $force = false, &$found = null, $cache_cb = null, &$cas_token = null ) { … … 315 317 316 318 /** 317 * Retrieve object from cache from specified server.318 * 319 * Gets an object from cache based on $key, $group and $server_key. In order to fully support the $cache_cb and $cas_token320 * parameters, the runtime cache is ignored by this function if either of those values are set. If either of321 * those values are set, the request is made directly to the memcached server for proper handling of the322 * callback and/or token.323 * 324 * @link http ://www.php.net/manual/en/memcached.getbykey.php325 * 326 * @param string 327 * @param string 328 * @param string 329 * @param bool 330 * @param null|bool 331 * @param null|string 332 * @param null|float 333 * @return bool|mixed 319 * Retrieves object from cache from specified server. 320 * 321 * Gets an object from cache based on $key, $group, and $server_key. In order to fully support 322 * the $cache_cb and $cas_token parameters, the runtime cache is ignored by this function 323 * if either of those values are set. In that case, the request is made directly 324 * to the memcached server for proper handling of the callback and/or token. 325 * 326 * @link https://www.php.net/manual/en/memcached.getbykey.php 327 * 328 * @param string $server_key The key identifying the server to store the value on. 329 * @param string $key The key under which to store the value. 330 * @param string $group The group value appended to the $key. 331 * @param bool $force Whether or not to force a cache invalidation. 332 * @param null|bool $found Variable passed by reference to determine if the value was found or not. 333 * @param null|string $cache_cb Read-through caching callback. 334 * @param null|float $cas_token The variable to store the CAS token in. 335 * @return bool|mixed Cached object value. 334 336 */ 335 337 function wp_cache_get_by_key( $server_key, $key, $group = '', $force = false, &$found = null, $cache_cb = null, &$cas_token = null ) { … … 344 346 345 347 /** 346 * Request multiple keys without blocking. 347 * 348 * @link http://www.php.net/manual/en/memcached.getdelayed.php 349 * 350 * @param string|array $keys Array or string of key(s) to request. 351 * @param string|array $groups Array or string of group(s) for the key(s). See buildKeys for more on how these are handled. 352 * @param bool $with_cas Whether to request CAS token values also. 353 * @param null $value_cb The result callback or NULL. 354 * @return bool Returns TRUE on success or FALSE on failure. 348 * Requests multiple keys without blocking. 349 * 350 * @link https://www.php.net/manual/en/memcached.getdelayed.php 351 * 352 * @param string|array $keys Array or string of key(s) to request. 353 * @param string|array $groups Array or string of group(s) for the key(s). 354 * See buildKeys for more on how these are handled. 355 * @param bool $with_cas Whether to request CAS token values also. 356 * @param null $value_cb The result callback or null. 357 * @return bool True on success, false on failure. 355 358 */ 356 359 function wp_cache_get_delayed( $keys, $groups = '', $with_cas = false, $value_cb = null ) { … … 360 363 361 364 /** 362 * Request multiple keys without blocking from a specified server. 363 * 364 * @link http://www.php.net/manual/en/memcached.getdelayed.php 365 * 366 * @param string $server_key The key identifying the server to store the value on. 367 * @param string|array $keys Array or string of key(s) to request. 368 * @param string|array $groups Array or string of group(s) for the key(s). See buildKeys for more on how these are handled. 369 * @param bool $with_cas Whether to request CAS token values also. 370 * @param null $value_cb The result callback or NULL. 371 * @return bool Returns TRUE on success or FALSE on failure. 365 * Requests multiple keys without blocking from a specified server. 366 * 367 * @link https://www.php.net/manual/en/memcached.getdelayed.php 368 * 369 * @param string $server_key The key identifying the server to store the value on. 370 * @param string|array $keys Array or string of key(s) to request. 371 * @param string|array $groups Array or string of group(s) for the key(s). 372 * See buildKeys for more on how these are handled. 373 * @param bool $with_cas Whether to request CAS token values also. 374 * @param null $value_cb The result callback or null. 375 * @return bool True on success, false on failure. 372 376 */ 373 377 function wp_cache_get_delayed_by_key( $server_key, $keys, $groups = '', $with_cas = false, $value_cb = null ) { … … 381 385 * See the buildKeys method definition to understand the $keys/$groups parameters. 382 386 * 383 * @link http://www.php.net/manual/en/memcached.getmulti.php 384 * 385 * @param array $keys Array of keys to retrieve. 386 * @param string|array $groups If string, used for all keys. If arrays, corresponds with the $keys array. 387 * @param null|array $cas_tokens The variable to store the CAS tokens for the found items. 388 * @param int $flags The flags for the get operation. 389 * @return bool|array Returns the array of found items or FALSE on failure. 387 * @link https://www.php.net/manual/en/memcached.getmulti.php 388 * 389 * @param array $keys Array of keys to retrieve. 390 * @param string|array $groups If string, used for all keys. 391 * If arrays, corresponds with the $keys array. 392 * @param null|array $cas_tokens The variable to store the CAS tokens for the found items. 393 * @param int $flags The flags for the get operation. 394 * @return bool|array The array of found items on success, false on failure. 390 395 */ 391 396 function wp_cache_get_multi( $keys, $groups = '', &$cas_tokens = null, $flags = null ) { … … 404 409 * See the buildKeys method definition to understand the $keys/$groups parameters. 405 410 * 406 * @link http://www.php.net/manual/en/memcached.getmultibykey.php 407 * 408 * @param string $server_key The key identifying the server to store the value on. 409 * @param array $keys Array of keys to retrieve. 410 * @param string|array $groups If string, used for all keys. If arrays, corresponds with the $keys array. 411 * @param null|array $cas_tokens The variable to store the CAS tokens for the found items. 412 * @param int $flags The flags for the get operation. 413 * @return bool|array Returns the array of found items or FALSE on failure. 411 * @link https://www.php.net/manual/en/memcached.getmultibykey.php 412 * 413 * @param string $server_key The key identifying the server to store the value on. 414 * @param array $keys Array of keys to retrieve. 415 * @param string|array $groups If string, used for all keys. 416 * If arrays, corresponds with the $keys array. 417 * @param null|array $cas_tokens The variable to store the CAS tokens for the found items. 418 * @param int $flags The flags for the get operation. 419 * @return bool|array The array of found items on success, false on failure. 414 420 */ 415 421 function wp_cache_get_multi_by_key( $server_key, $keys, $groups = '', &$cas_tokens = null, $flags = null ) { … … 424 430 425 431 /** 426 * Retrieve a Memcached option value.427 * 428 * @link http ://www.php.net/manual/en/memcached.getoption.php429 * 430 * @param int 431 * @return mixed Returns the value of the requested option, or FALSE on error.432 * Retrieves a Memcached option value. 433 * 434 * @link https://www.php.net/manual/en/memcached.getoption.php 435 * 436 * @param int $option One of the Memcached::OPT_* constants. 437 * @return mixed The value of the requested option on success, false on failure. 432 438 */ 433 439 function wp_cache_get_option( $option ) { … … 437 443 438 444 /** 439 * Return the result code of the last option.440 * 441 * @link http ://www.php.net/manual/en/memcached.getresultcode.php442 * 443 * @return int 445 * Returns the result code of the last option. 446 * 447 * @link https://www.php.net/manual/en/memcached.getresultcode.php 448 * 449 * @return int Result code of the last Memcached operation. 444 450 */ 445 451 function wp_cache_get_result_code() { … … 451 457 * Return the message describing the result of the last operation. 452 458 * 453 * @link http ://www.php.net/manual/en/memcached.getresultmessage.php454 * 455 * @return string 459 * @link https://www.php.net/manual/en/memcached.getresultmessage.php 460 * 461 * @return string Message describing the result of the last Memcached operation. 456 462 */ 457 463 function wp_cache_get_result_message() { … … 461 467 462 468 /** 463 * Get server information by key.464 * 465 * @link http ://www.php.net/manual/en/memcached.getserverbykey.php466 * 467 * @param string 468 * @return array Array with host, post, and weight on success, FALSEon failure.469 * Gets server information by key. 470 * 471 * @link https://www.php.net/manual/en/memcached.getserverbykey.php 472 * 473 * @param string $server_key The key identifying the server to store the value on. 474 * @return array Array with host, post, and weight on success, fales on failure. 469 475 */ 470 476 function wp_cache_get_server_by_key( $server_key ) { … … 474 480 475 481 /** 476 * Get the list of servers in the pool.477 * 478 * @link http ://www.php.net/manual/en/memcached.getserverlist.php479 * 480 * @return array 482 * Gets the list of servers in the pool. 483 * 484 * @link https://www.php.net/manual/en/memcached.getserverlist.php 485 * 486 * @return array The list of all servers in the server pool. 481 487 */ 482 488 function wp_cache_get_server_list() { … … 486 492 487 493 /** 488 * Get server pool statistics.489 * 490 * @link http ://www.php.net/manual/en/memcached.getstats.php491 * 492 * @return array 494 * Gets server pool statistics. 495 * 496 * @link https://www.php.net/manual/en/memcached.getstats.php 497 * 498 * @return array Array of server statistics, one entry per server. 493 499 */ 494 500 function wp_cache_get_stats() { … … 498 504 499 505 /** 500 * Get server pool memcached version information.501 * 502 * @link http ://www.php.net/manual/en/memcached.getversion.php503 * 504 * @return array 506 * Gets server pool memcached version information. 507 * 508 * @link https://www.php.net/manual/en/memcached.getversion.php 509 * 510 * @return array Array of server versions, one entry per server. 505 511 */ 506 512 function wp_cache_get_version() { … … 510 516 511 517 /** 512 * Increment a numeric item's value.513 * 514 * @link http ://www.php.net/manual/en/memcached.increment.php515 * 516 * @param string 517 * @param int 518 * @param string 519 * @return int|bool Returns item's new value on success or FALSEon failure.518 * Increments a numeric item's value. 519 * 520 * @link https://www.php.net/manual/en/memcached.increment.php 521 * 522 * @param string $key The key under which to store the value. 523 * @param int $offset The amount by which to increment the item's value. 524 * @param string $group The group value appended to the $key. 525 * @return int|bool Item's new value on success, false on failure. 520 526 */ 521 527 function wp_cache_increment( $key, $offset = 1, $group = '' ) { … … 525 531 526 532 /** 527 * Increment a numeric item's value.528 * 529 * This is the same as wp_cache_increment , but kept for back compatibility. The original530 * WordPress caching backends use wp_cache_incr. I want both to work.531 * 532 * @link http ://www.php.net/manual/en/memcached.increment.php533 * 534 * @param string 535 * @param int 536 * @param string 537 * @return int|bool Returns item's new value on success or FALSEon failure.533 * Increments a numeric item's value. 534 * 535 * This is the same as wp_cache_increment(), but kept for backward compatibility. 536 * The original WordPress caching backends use wp_cache_incr(). 537 * 538 * @link https://www.php.net/manual/en/memcached.increment.php 539 * 540 * @param string $key The key under which to store the value. 541 * @param int $offset The amount by which to increment the item's value. 542 * @param string $group The group value appended to the $key. 543 * @return int|bool Item's new value on success, false on failure. 538 544 */ 539 545 function wp_cache_incr( $key, $offset = 1, $group = '' ) { … … 542 548 543 549 /** 544 * Prepend data to an existing item.550 * Prepends data to an existing item. 545 551 * 546 552 * This method should throw an error if it is used with compressed data. This is an expected behavior. 547 * Memcached casts the value to be prepended to the initial value to the type of the initial value. Be548 * careful as this leads to unexpected behavior at times. For instance, prepending (float) 45.23 to549 * (int) 23 will result in 45, because the value is first combined (45.2323) then cast to "integer"553 * Memcached casts the value to be prepended to the initial value to the type of the initial value. 554 * Be careful as this leads to unexpected behavior at times. For instance, prepending (float) 45.23 555 * to (int) 23 will result in 45, because the value is first combined (45.2323) then cast to "integer" 550 556 * (the original value), which will be (int) 45. Due to how memcached treats types, the behavior has been 551 * mimicked in the internal cache to produce similar results and improve consistency. It is recommend 557 * mimicked in the internal cache to produce similar results and improve consistency. It is recommended 552 558 * that prepends only occur with data of the same type. 553 559 * 554 * @link http ://www.php.net/manual/en/memcached.prepend.php555 * 556 * @param string $keyThe key under which to store the value.557 * @param string $valueMust be string as prepending mixed values is not well-defined.558 * @param string $groupThe group value prepended to the $key.559 * @return bool Returns TRUE on success or FALSEon failure.560 * @link https://www.php.net/manual/en/memcached.prepend.php 561 * 562 * @param string $key The key under which to store the value. 563 * @param string $value Must be string as prepending mixed values is not well-defined. 564 * @param string $group The group value prepended to the $key. 565 * @return bool True on success, false on failure. 560 566 */ 561 567 function wp_cache_prepend( $key, $value, $group = '' ) { … … 565 571 566 572 /** 567 * Append data to an existing item by server key.573 * Appends data to an existing item by server key. 568 574 * 569 575 * This method should throw an error if it is used with compressed data. This is an expected behavior. 570 * Memcached casts the value to be prepended to the initial value to the type of the initial value. Be571 * careful as this leads to unexpected behavior at times. For instance, prepending (float) 45.23 to572 * (int) 23 will result in 45, because the value is first combined (45.2323) then cast to "integer"576 * Memcached casts the value to be prepended to the initial value to the type of the initial value. 577 * Be careful as this leads to unexpected behavior at times. For instance, prepending (float) 45.23 578 * to (int) 23 will result in 45, because the value is first combined (45.2323) then cast to "integer" 573 579 * (the original value), which will be (int) 45. Due to how memcached treats types, the behavior has been 574 * mimicked in the internal cache to produce similar results and improve consistency. It is recommend 580 * mimicked in the internal cache to produce similar results and improve consistency. It is recommended 575 581 * that prepends only occur with data of the same type. 576 582 * 577 * @link http ://www.php.net/manual/en/memcached.prependbykey.php578 * 579 * @param string $server_keyThe key identifying the server to store the value on.580 * @param string $keyThe key under which to store the value.581 * @param string $valueMust be string as prepending mixed values is not well-defined.582 * @param string $groupThe group value prepended to the $key.583 * @return bool Returns TRUE on success or FALSEon failure.583 * @link https://www.php.net/manual/en/memcached.prependbykey.php 584 * 585 * @param string $server_key The key identifying the server to store the value on. 586 * @param string $key The key under which to store the value. 587 * @param string $value Must be string as prepending mixed values is not well-defined. 588 * @param string $group The group value prepended to the $key. 589 * @return bool True on success, false on failure. 584 590 */ 585 591 function wp_cache_prepend_by_key( $server_key, $key, $value, $group = '' ) { … … 591 597 * Replaces a value in cache. 592 598 * 593 * This method is similar to "add"; however, is does not successfully set a value if594 * the object's key is not already set in cache.595 * 596 * @link http ://www.php.net/manual/en/memcached.replace.php597 * 598 * @param string 599 * @param mixed 600 * @param string 601 * @param int 602 * @return bool Returns TRUE on success or FALSEon failure.599 * This method is similar to "add"; however, is does not successfully set a value 600 * if the object's key is not already set in cache. 601 * 602 * @link https://www.php.net/manual/en/memcached.replace.php 603 * 604 * @param string $key The key under which to store the value. 605 * @param mixed $value The value to store. 606 * @param string $group The group value appended to the $key. 607 * @param int $expiration The expiration time, defaults to 0. 608 * @return bool True on success, false on failure. 603 609 */ 604 610 function wp_cache_replace( $key, $value, $group = '', $expiration = 0 ) { … … 610 616 * Replaces a value in cache on a specific server. 611 617 * 612 * This method is similar to "addByKey"; however, is does not successfully set a value if613 * the object's key is not already set in cache.614 * 615 * @link http ://www.php.net/manual/en/memcached.addbykey.php616 * 617 * @param string $server_keyThe key identifying the server to store the value on.618 * @param string $keyThe key under which to store the value.619 * @param mixed $valueThe value to store.620 * @param string $groupThe group value appended to the $key.621 * @param int $expirationThe expiration time, defaults to 0.622 * @return bool Returns TRUE on success or FALSEon failure.618 * This method is similar to "addByKey"; however, is does not successfully set a value 619 * if the object's key is not already set in cache. 620 * 621 * @link https://www.php.net/manual/en/memcached.addbykey.php 622 * 623 * @param string $server_key The key identifying the server to store the value on. 624 * @param string $key The key under which to store the value. 625 * @param mixed $value The value to store. 626 * @param string $group The group value appended to the $key. 627 * @param int $expiration The expiration time, defaults to 0. 628 * @return bool True on success, false on failure. 623 629 */ 624 630 function wp_cache_replace_by_key( $server_key, $key, $value, $group = '', $expiration = 0 ) { … … 632 638 * The value is set whether or not this key already exists in memcached. 633 639 * 634 * @link http ://www.php.net/manual/en/memcached.set.php635 * 636 * @param string 637 * @param mixed 638 * @param string 639 * @param int 640 * @return bool Returns TRUE on success or FALSEon failure.640 * @link https://www.php.net/manual/en/memcached.set.php 641 * 642 * @param string $key The key under which to store the value. 643 * @param mixed $value The value to store. 644 * @param string $group The group value appended to the $key. 645 * @param int $expiration The expiration time, defaults to 0. 646 * @return bool True on success, false on failure. 641 647 */ 642 648 function wp_cache_set( $key, $value, $group = '', $expiration = 0 ) { … … 650 656 * The value is set whether or not this key already exists in memcached. 651 657 * 652 * @link http ://www.php.net/manual/en/memcached.set.php653 * 654 * @param string $server_keyThe key identifying the server to store the value on.655 * @param string $keyThe key under which to store the value.656 * @param mixed $valueThe value to store.657 * @param string $groupThe group value appended to the $key.658 * @param int $expirationThe expiration time, defaults to 0.659 * @return bool Returns TRUE on success or FALSEon failure.658 * @link https://www.php.net/manual/en/memcached.set.php 659 * 660 * @param string $server_key The key identifying the server to store the value on. 661 * @param string $key The key under which to store the value. 662 * @param mixed $value The value to store. 663 * @param string $group The group value appended to the $key. 664 * @param int $expiration The expiration time, defaults to 0. 665 * @return bool True on success, false on failure. 660 666 */ 661 667 function wp_cache_set_by_key( $server_key, $key, $value, $group = '', $expiration = 0 ) { … … 665 671 666 672 /** 667 * Set multiple values to cache at once.673 * Sets multiple values to cache at once. 668 674 * 669 675 * By sending an array of $items to this function, all values are saved at once to … … 673 679 * final key for the object. 674 680 * 675 * @param array 676 * @param string|array 677 * @param int 678 * @return bool Returns TRUE on success or FALSEon failure.681 * @param array $items An array of key/value pairs to store on the server. 682 * @param string|array $groups Group(s) to merge with key(s) in $items. 683 * @param int $expiration The expiration time, defaults to 0. 684 * @return bool True on success, false on failure. 679 685 */ 680 686 function wp_cache_set_multi( $items, $groups = '', $expiration = 0 ) { … … 684 690 685 691 /** 686 * Set multiple values to cache at once on specified server.692 * Sets multiple values to cache at once on specified server. 687 693 * 688 694 * By sending an array of $items to this function, all values are saved at once to … … 692 698 * final key for the object. 693 699 * 694 * @param string 695 * @param array 696 * @param string|array 697 * @param int 698 * @return bool Returns TRUE on success or FALSEon failure.700 * @param string $server_key The key identifying the server to store the value on. 701 * @param array $items An array of key/value pairs to store on the server. 702 * @param string|array $groups Group(s) to merge with key(s) in $items. 703 * @param int $expiration The expiration time, defaults to 0. 704 * @return bool True on success, false on failure. 699 705 */ 700 706 function wp_cache_set_multi_by_key( $server_key, $items, $groups = 'default', $expiration = 0 ) { … … 704 710 705 711 /** 706 * Set a Memcached option.707 * 708 * @link http ://www.php.net/manual/en/memcached.setoption.php709 * 710 * @param int 711 * @param mixed 712 * @return bool Returns TRUE on success or FALSEon failure.712 * Sets a Memcached option. 713 * 714 * @link https://www.php.net/manual/en/memcached.setoption.php 715 * 716 * @param int $option Option name. 717 * @param mixed $value Option value. 718 * @return bool True on success, false on failure. 713 719 */ 714 720 function wp_cache_set_option( $option, $value ) { … … 718 724 719 725 /** 720 * Switch blog prefix, which changes the cache that is accessed.721 * 722 * @param int $blog_idBlog to switch to.726 * Switches blog prefix, which changes the cache that is accessed. 727 * 728 * @param int $blog_id Blog to switch to. 723 729 * @return void 724 730 */ … … 732 738 * Sets up Object Cache Global and assigns it. 733 739 * 734 * @global WP_Object_Cache $wp_object_cacheWordPress Object Cache735 * @return 740 * @global WP_Object_Cache $wp_object_cache WordPress Object Cache 741 * @return void 736 742 */ 737 743 function wp_cache_init() { … … 743 749 * Adds a group or set of groups to the list of non-persistent groups. 744 750 * 745 * @param string|array $groupsA group or an array of groups to add.746 * @return 751 * @param string|array $groups A group or an array of groups to add. 752 * @return void 747 753 */ 748 754 function wp_cache_add_global_groups( $groups ) { … … 754 760 * Adds a group or set of groups to the list of non-Memcached groups. 755 761 * 756 * @param string|array $groupsA group or an array of groups to add.757 * @return 762 * @param string|array $groups A group or an array of groups to add. 763 * @return void 758 764 */ 759 765 function wp_cache_add_non_persistent_groups( $groups ) { … … 815 821 816 822 /** 817 * Instantiate the Memcached class.823 * Instantiates the Memcached class. 818 824 * 819 825 * Instantiates the Memcached class and returns adds the servers specified 820 826 * in the $memcached_servers global array. 821 827 * 822 * @link http://www.php.net/manual/en/memcached.construct.php 823 * 824 * @param null $persistent_id To create an instance that persists between requests, use persistent_id to specify a unique ID for the instance. 828 * @link https://www.php.net/manual/en/memcached.construct.php 829 * 830 * @param null $persistent_id To create an instance that persists between requests, 831 * use persistent_id to specify a unique ID for the instance. 825 832 */ 826 833 public function __construct( $persistent_id = null ) { … … 842 849 843 850 /** 844 * This approach is borrowed from Sivel and Boren. Use the salt for easy cache invalidation and for845 * multi single WP installations on the same server.851 * This approach is borrowed from Sivel and Boren. Use the salt for easy cache invalidation 852 * and for multi single WP installations on the same server. 846 853 */ 847 854 if ( ! defined( 'WP_CACHE_KEY_SALT' ) ) { … … 849 856 } 850 857 851 // Assign global and blog prefixes for use with keys 858 // Assign global and blog prefixes for use with keys. 852 859 if ( function_exists( 'is_multisite' ) ) { 853 860 $this->global_prefix = ( is_multisite() || defined( 'CUSTOM_USER_TABLE' ) && defined( 'CUSTOM_USER_META_TABLE' ) ) ? '' : $table_prefix; … … 855 862 } 856 863 857 // Setup cacheable values for handling expiration times 864 // Setup cacheable values for handling expiration times. 858 865 $this->thirty_days = 60 * 60 * 24 * 30; 859 866 $this->now = time(); … … 866 873 * returns false. 867 874 * 868 * @link http://www.php.net/manual/en/memcached.add.php869 * 870 * @param string $keyThe key under which to store the value.871 * @param mixed $valueThe value to store.872 * @param string $groupThe group value appended to the $key.873 * @param int $expirationThe expiration time, defaults to 0.874 * @param string $server_keyThe key identifying the server to store the value on.875 * @param bool $by_key True to store in internal cache by key; false to not store by key876 * @return bool Returns TRUE on success or FALSEon failure.875 * @link https://www.php.net/manual/en/memcached.add.php 876 * 877 * @param string $key The key under which to store the value. 878 * @param mixed $value The value to store. 879 * @param string $group The group value appended to the $key. 880 * @param int $expiration The expiration time, defaults to 0. 881 * @param string $server_key The key identifying the server to store the value on. 882 * @param bool $by_key True to store in internal cache by key; false to not store by key. 883 * @return bool True on success, false on failure. 877 884 */ 878 885 public function add( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by_key = false ) { … … 890 897 $expiration = $this->sanitize_expiration( $expiration ); 891 898 892 // If group is a non-Memcached group, save to runtime cache, not Memcached 899 // If group is a non-Memcached group, save to runtime cache, not Memcached. 893 900 if ( in_array( $group, $this->no_mc_groups, true ) ) { 894 901 895 // Add does not set the value if the key exists; mimic that here 902 // Add does not set the value if the key exists; mimic that here. 896 903 if ( isset( $this->cache[ $derived_key ] ) ) { 897 904 return false; … … 903 910 } 904 911 905 // Save to Memcached 912 // Save to Memcached. 906 913 if ( $by_key ) { 907 914 $result = $this->m->addByKey( $server_key, $derived_key, $value, $expiration ); … … 910 917 } 911 918 912 // Store in runtime cache if add was successful 919 // Store in runtime cache if add was successful. 913 920 if ( Memcached::RES_SUCCESS === $this->getResultCode() ) { 914 921 $this->add_to_internal_cache( $derived_key, $value ); … … 926 933 * specified server_key. 927 934 * 928 * @link http://www.php.net/manual/en/memcached.addbykey.php929 * 930 * @param string $server_keyThe key identifying the server to store the value on.931 * @param string $keyThe key under which to store the value.932 * @param mixed $valueThe value to store.933 * @param string $groupThe group value appended to the $key.934 * @param int $expirationThe expiration time, defaults to 0.935 * @return bool Returns TRUE on success or FALSEon failure.935 * @link https://www.php.net/manual/en/memcached.addbykey.php 936 * 937 * @param string $server_key The key identifying the server to store the value on. 938 * @param string $key The key under which to store the value. 939 * @param mixed $value The value to store. 940 * @param string $group The group value appended to the $key. 941 * @param int $expiration The expiration time, defaults to 0. 942 * @return bool True on success, false on failure. 936 943 */ 937 944 public function addByKey( $server_key, $key, $value, $group = 'default', $expiration = 0 ) { … … 940 947 941 948 /** 942 * Add a single server to the list of Memcached servers. 943 * 944 * @link http://www.php.net/manual/en/memcached.addserver.php 945 * 946 * @param string $host The hostname of the memcache server. 947 * @param int $port The port on which memcache is running. 948 * @param int $weight The weight of the server relative to the total weight of all the servers in the pool. 949 * @return bool Returns TRUE on success or FALSE on failure. 949 * Adds a single server to the list of Memcached servers. 950 * 951 * @link https://www.php.net/manual/en/memcached.addserver.php 952 * 953 * @param string $host The hostname of the memcache server. 954 * @param int $port The port on which memcache is running. 955 * @param int $weight The weight of the server relative to the total weight 956 * of all the servers in the pool. 957 * @return bool True on success, false on failure. 950 958 */ 951 959 public function addServer( $host, $port, $weight = 0 ) { … … 963 971 * weight value: $servers = array( array( '127.0.0.1', 11211, 0 ) ); 964 972 * 965 * @link http://www.php.net/manual/en/memcached.addservers.php966 * 967 * @param array $serversArray of server to register.968 * @return bool True on success;false on failure.973 * @link https://www.php.net/manual/en/memcached.addservers.php 974 * 975 * @param array $servers Array of server to register. 976 * @return bool True on success, false on failure. 969 977 */ 970 978 public function addServers( $servers ) { … … 977 985 978 986 /** 979 * Append data to an existing item.980 * 981 * This method should throw an error if it is used with compressed data. This982 * is an expected behavior. Memcached casts the value to be appended to the initial value to the983 * t ype of the initial value. Be careful as this leads to unexpected behavior at times. Due to984 * how memcached treats types, the behavior has been mimicked in the internal cache to produce985 * similar results and improve consistency. It is recommend that appends only occur with data of987 * Appends data to an existing item. 988 * 989 * This method should throw an error if it is used with compressed data. 990 * This is an expected behavior. Memcached casts the value to be appended to the initial value 991 * to the type of the initial value. Be careful as this leads to unexpected behavior at times. 992 * Due to how memcached treats types, the behavior has been mimicked in the internal cache to produce 993 * similar results and improve consistency. It is recommended that appends only occur with data of 986 994 * the same type. 987 995 * 988 * @link http://www.php.net/manual/en/memcached.append.php989 * 990 * @param string $keyThe key under which to store the value.991 * @param mixed $valueMust be string as appending mixed values is not well-defined.992 * @param string $groupThe group value appended to the $key.993 * @param string $server_keyThe key identifying the server to store the value on.994 * @param bool $by_key True to store in internal cache by key; false to not store by key995 * @return bool Returns TRUE on success or FALSEon failure.996 * @link https://www.php.net/manual/en/memcached.append.php 997 * 998 * @param string $key The key under which to store the value. 999 * @param mixed $value Must be string as appending mixed values is not well-defined. 1000 * @param string $group The group value appended to the $key. 1001 * @param string $server_key The key identifying the server to store the value on. 1002 * @param bool $by_key True to store in internal cache by key; false to not store by key. 1003 * @return bool True on success, false on failure. 996 1004 */ 997 1005 public function append( $key, $value, $group = 'default', $server_key = '', $by_key = false ) { … … 1002 1010 $derived_key = $this->buildKey( $key, $group ); 1003 1011 1004 // If group is a non-Memcached group, append to runtime cache value, not Memcached 1012 // If group is a non-Memcached group, append to runtime cache value, not Memcached. 1005 1013 if ( in_array( $group, $this->no_mc_groups, true ) ) { 1006 1014 if ( ! isset( $this->cache[ $derived_key ] ) ) { … … 1013 1021 } 1014 1022 1015 // Append to Memcached value 1023 // Append to Memcached value. 1016 1024 if ( $by_key ) { 1017 1025 $result = $this->m->appendByKey( $server_key, $derived_key, $value ); … … 1020 1028 } 1021 1029 1022 // Store in runtime cache if add was successful 1030 // Store in runtime cache if add was successful. 1023 1031 if ( Memcached::RES_SUCCESS === $this->getResultCode() ) { 1024 1032 $combined = $this->combine_values( $this->cache[ $derived_key ], $value, 'app' ); … … 1030 1038 1031 1039 /** 1032 * Append data to an existing item by server key.1033 * 1034 * This method should throw an error if it is used with compressed data. This1035 * is an expected behavior. Memcached casts the value to be appended to the initial value to the1036 * t ype of the initial value. Be careful as this leads to unexpected behavior at times. Due to1037 * how memcached treats types, the behavior has been mimicked in the internal cache to produce1038 * similar results and improve consistency. It is recommend that appends only occur with data of1040 * Appends data to an existing item by server key. 1041 * 1042 * This method should throw an error if it is used with compressed data. 1043 * This is an expected behavior. Memcached casts the value to be appended to the initial value 1044 * to the type of the initial value. Be careful as this leads to unexpected behavior at times. 1045 * Due to how memcached treats types, the behavior has been mimicked in the internal cache to produce 1046 * similar results and improve consistency. It is recommended that appends only occur with data of 1039 1047 * the same type. 1040 1048 * 1041 * @link http://www.php.net/manual/en/memcached.appendbykey.php1042 * 1043 * @param string $server_keyThe key identifying the server to store the value on.1044 * @param string $keyThe key under which to store the value.1045 * @param mixed $value Must be string as appending mixed values is not well-defined1046 * @param string $groupThe group value appended to the $key.1047 * @return bool Returns TRUE on success or FALSEon failure.1049 * @link https://www.php.net/manual/en/memcached.appendbykey.php 1050 * 1051 * @param string $server_key The key identifying the server to store the value on. 1052 * @param string $key The key under which to store the value. 1053 * @param mixed $value Must be string as appending mixed values is not well-defined. 1054 * @param string $group The group value appended to the $key. 1055 * @return bool True on success, false on failure. 1048 1056 */ 1049 1057 public function appendByKey( $server_key, $key, $value, $group = 'default' ) { … … 1054 1062 * Performs a "check and set" to store data. 1055 1063 * 1056 * The set will be successful only if the no other request has updated the value since it was fetched since1057 * this request.1058 * 1059 * @link http://www.php.net/manual/en/memcached.cas.php1060 * 1061 * @param float $cas_tokenUnique value associated with the existing item. Generated by memcached.1062 * @param string $keyThe key under which to store the value.1063 * @param mixed $valueThe value to store.1064 * @param string $groupThe group value appended to the $key.1065 * @param int $expirationThe expiration time, defaults to 0.1066 * @param string $server_keyThe key identifying the server to store the value on.1067 * @param bool $by_key True to store in internal cache by key; false to not store by key1068 * @return bool Returns TRUE on success or FALSEon failure.1064 * The set will be successful only if the no other request has updated the value 1065 * since it was fetched by this request. 1066 * 1067 * @link https://www.php.net/manual/en/memcached.cas.php 1068 * 1069 * @param float $cas_token Unique value associated with the existing item. Generated by memcached. 1070 * @param string $key The key under which to store the value. 1071 * @param mixed $value The value to store. 1072 * @param string $group The group value appended to the $key. 1073 * @param int $expiration The expiration time, defaults to 0. 1074 * @param string $server_key The key identifying the server to store the value on. 1075 * @param bool $by_key True to store in internal cache by key; false to not store by key. 1076 * @return bool True on success, false on failure. 1069 1077 */ 1070 1078 public function cas( $cas_token, $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by_key = false ) { … … 1082 1090 } 1083 1091 1084 // Save to Memcached 1092 // Save to Memcached. 1085 1093 if ( $by_key ) { 1086 1094 $result = $this->m->casByKey( $cas_token, $server_key, $derived_key, $value, $expiration ); … … 1089 1097 } 1090 1098 1091 // Store in runtime cache if cas was successful 1099 // Store in runtime cache if cas was successful. 1092 1100 if ( Memcached::RES_SUCCESS === $this->getResultCode() ) { 1093 1101 $this->add_to_internal_cache( $derived_key, $value ); … … 1100 1108 * Performs a "check and set" to store data with a server key. 1101 1109 * 1102 * The set will be successful only if the no other request has updated the value since it was fetched by1103 * this request.1104 * 1105 * @link http://www.php.net/manual/en/memcached.casbykey.php1106 * 1107 * @param string $server_keyThe key identifying the server to store the value on.1108 * @param float $cas_tokenUnique value associated with the existing item. Generated by memcached.1109 * @param string $keyThe key under which to store the value.1110 * @param mixed $valueThe value to store.1111 * @param string $groupThe group value appended to the $key.1112 * @param int $expirationThe expiration time, defaults to 0.1113 * @return bool Returns TRUE on success or FALSEon failure.1110 * The set will be successful only if the no other request has updated the value 1111 * since it was fetched by this request. 1112 * 1113 * @link https://www.php.net/manual/en/memcached.casbykey.php 1114 * 1115 * @param string $server_key The key identifying the server to store the value on. 1116 * @param float $cas_token Unique value associated with the existing item. Generated by memcached. 1117 * @param string $key The key under which to store the value. 1118 * @param mixed $value The value to store. 1119 * @param string $group The group value appended to the $key. 1120 * @param int $expiration The expiration time, defaults to 0. 1121 * @return bool True on success, false on failure. 1114 1122 */ 1115 1123 public function casByKey( $cas_token, $server_key, $key, $value, $group = 'default', $expiration = 0 ) { … … 1118 1126 1119 1127 /** 1120 * Decrement a numeric item's value.1121 * 1122 * @link http ://www.php.net/manual/en/memcached.decrement.php1123 * 1124 * @param string 1125 * @param int 1126 * @param string 1127 * @return int|bool Returns item's new value on success or FALSEon failure.1128 * Decrements a numeric item's value. 1129 * 1130 * @link https://www.php.net/manual/en/memcached.decrement.php 1131 * 1132 * @param string $key The key under which to store the value. 1133 * @param int $offset The amount by which to decrement the item's value. 1134 * @param string $group The group value appended to the $key. 1135 * @return int|bool Item's new value on success, false on failure. 1128 1136 */ 1129 1137 public function decrement( $key, $offset = 1, $group = 'default' ) { 1130 1138 $derived_key = $this->buildKey( $key, $group ); 1131 1139 1132 // Decrement values in no_mc_groups 1140 // Decrement values in no_mc_groups. 1133 1141 if ( in_array( $group, $this->no_mc_groups, true ) ) { 1134 1142 1135 // Only decrement if the key already exists and value is 0 or greater (mimics memcached behavior) 1143 // Only decrement if the key already exists and value is 0 or greater (mimics memcached behavior). 1136 1144 if ( isset( $this->cache[ $derived_key ] ) && $this->cache[ $derived_key ] >= 0 ) { 1137 1145 1138 // If numeric, subtract; otherwise, consider it 0 and do nothing 1146 // If numeric, subtract; otherwise, consider it 0 and do nothing. 1139 1147 if ( is_numeric( $this->cache[ $derived_key ] ) ) { 1140 1148 $this->cache[ $derived_key ] -= (int) $offset; … … 1143 1151 } 1144 1152 1145 // Returned value cannot be less than 0 1153 // Returned value cannot be less than 0. 1146 1154 if ( $this->cache[ $derived_key ] < 0 ) { 1147 1155 $this->cache[ $derived_key ] = 0; … … 1164 1172 1165 1173 /** 1166 * Decrement a numeric item's value. 1167 * 1168 * Alias for $this->decrement. Other caching backends use this abbreviated form of the function. It *may* cause 1169 * breakage somewhere, so it is nice to have. This function will also allow the core unit tests to pass. 1170 * 1171 * @param string $key The key under which to store the value. 1172 * @param int $offset The amount by which to decrement the item's value. 1173 * @param string $group The group value appended to the $key. 1174 * @return int|bool Returns item's new value on success or FALSE on failure. 1174 * Decrements a numeric item's value. 1175 * 1176 * Alias for $this->decrement(). Other caching backends use this abbreviated form 1177 * of the function. It *may* cause breakage somewhere, so it is nice to have. 1178 * This function will also allow the core unit tests to pass. 1179 * 1180 * @param string $key The key under which to store the value. 1181 * @param int $offset The amount by which to decrement the item's value. 1182 * @param string $group The group value appended to the $key. 1183 * @return int|bool Item's new value on success, false on failure. 1175 1184 */ 1176 1185 public function decr( $key, $offset = 1, $group = 'default' ) { … … 1179 1188 1180 1189 /** 1181 * Remove the item from the cache.1182 * 1183 * Remove an item from memcached with identified by $key after $time seconds. The1184 * $time parameter allows an object to be queued for deletion without immediately1185 * deleting. Between the time that it is queued and the time it's deleted, add,1186 * replace, and get will fail, but set will succeed.1187 * 1188 * @link http ://www.php.net/manual/en/memcached.delete.php1189 * 1190 * @param string$key The key under which to store the value.1191 * @param string$group The group value appended to the $key.1192 * @param int$time The amount of time the server will wait to delete the item in seconds.1193 * @param string$server_key The key identifying the server to store the value on.1194 * @param bool $by_key True to store in internal cache by key; false to not store by key1195 * @return bool Returns TRUE on success or FALSEon failure.1190 * Removes the item from the cache. 1191 * 1192 * Removes an item from memcached with identified by $key after $time seconds. 1193 * The $time parameter allows an object to be queued for deletion without 1194 * immediately deleting. Between the time that it is queued and the time it's deleted, 1195 * add, replace, and get will fail, but set will succeed. 1196 * 1197 * @link https://www.php.net/manual/en/memcached.delete.php 1198 * 1199 * @param string $key The key under which to store the value. 1200 * @param string $group The group value appended to the $key. 1201 * @param int $time The amount of time the server will wait to delete the item in seconds. 1202 * @param string $server_key The key identifying the server to store the value on. 1203 * @param bool $by_key True to store in internal cache by key; false to not store by key. 1204 * @return bool True on success, false on failure. 1196 1205 */ 1197 1206 public function delete( $key, $group = 'default', $time = 0, $server_key = '', $by_key = false ) { 1198 1207 $derived_key = $this->buildKey( $key, $group ); 1199 1208 1200 // Remove from no_mc_groups array 1209 // Remove from no_mc_groups array. 1201 1210 if ( in_array( $group, $this->no_mc_groups, true ) ) { 1202 1211 if ( isset( $this->cache[ $derived_key ] ) ) { … … 1221 1230 1222 1231 /** 1223 * Remove the item from the cache by server key.1224 * 1225 * Remove an item from memcached with identified by $key after $time seconds. The1226 * $time parameter allows an object to be queued for deletion without immediately1227 * deleting. Between the time that it is queued and the time it's deleted, add,1228 * replace, and get will fail, but set will succeed.1229 * 1230 * @link http ://www.php.net/manual/en/memcached.deletebykey.php1231 * 1232 * @param string$server_key The key identifying the server to store the value on.1233 * @param string$key The key under which to store the value.1234 * @param string$group The group value appended to the $key.1235 * @param int$time The amount of time the server will wait to delete the item in seconds.1236 * @return bool Returns TRUE on success or FALSEon failure.1232 * Removes the item from the cache by server key. 1233 * 1234 * Removes an item from memcached with identified by $key after $time seconds. 1235 * The $time parameter allows an object to be queued for deletion without 1236 * immediately deleting. Between the time that it is queued and the time it's deleted, 1237 * add, replace, and get will fail, but set will succeed. 1238 * 1239 * @link https://www.php.net/manual/en/memcached.deletebykey.php 1240 * 1241 * @param string $server_key The key identifying the server to store the value on. 1242 * @param string $key The key under which to store the value. 1243 * @param string $group The group value appended to the $key. 1244 * @param int $time The amount of time the server will wait to delete the item in seconds. 1245 * @return bool True on success, false on failure. 1237 1246 */ 1238 1247 public function deleteByKey( $server_key, $key, $group = 'default', $time = 0 ) { … … 1241 1250 1242 1251 /** 1243 * Fetch the next result.1244 * 1245 * @link http ://www.php.net/manual/en/memcached.fetch.php1246 * 1247 * @return array| bool Returns the next result or FALSEon failure.1252 * Fetches the next result. 1253 * 1254 * @link https://www.php.net/manual/en/memcached.fetch.php 1255 * 1256 * @return array|false The next result on success, false on failure. 1248 1257 */ 1249 1258 public function fetch() { … … 1252 1261 1253 1262 /** 1254 * Fetch all remaining results from the last request.1255 * 1256 * @link http ://www.php.net/manual/en/memcached.fetchall.php1257 * 1258 * @return array|bool Returns the results or FALSEon failure.1263 * Fetches all remaining results from the last request. 1264 * 1265 * @link https://www.php.net/manual/en/memcached.fetchall.php 1266 * 1267 * @return array|false The results on success, false on failure. 1259 1268 */ 1260 1269 public function fetchAll() { … … 1263 1272 1264 1273 /** 1265 * Invalidate all items in the cache.1266 * 1267 * @link http ://www.php.net/manual/en/memcached.flush.php1268 * 1269 * @param int $delayNumber of seconds to wait before invalidating the items.1270 * @return bool Returns TRUE on success or FALSEon failure.1274 * Invalidates all items in the cache. 1275 * 1276 * @link https://www.php.net/manual/en/memcached.flush.php 1277 * 1278 * @param int $delay Number of seconds to wait before invalidating the items. 1279 * @return bool True on success, false on failure. 1271 1280 */ 1272 1281 public function flush( $delay = 0 ) { 1273 1282 $result = $this->m->flush( $delay ); 1274 1283 1275 // Only reset the runtime cache if memcached was properly flushed 1284 // Only reset the runtime cache if memcached was properly flushed. 1276 1285 if ( Memcached::RES_SUCCESS === $this->getResultCode() ) { 1277 1286 $this->cache = array(); … … 1282 1291 1283 1292 /** 1284 * Retrieve object from cache. 1285 * 1286 * Gets an object from cache based on $key and $group. In order to fully support the $cache_cb and $cas_token 1287 * parameters, the runtime cache is ignored by this function if either of those values are set. If either of 1288 * those values are set, the request is made directly to the memcached server for proper handling of the 1289 * callback and/or token. Note that the $cas_token variable cannot be directly passed to the function. The 1290 * variable need to be first defined with a non null value. 1291 * 1292 * If using the $cache_cb argument, the new value will always have an expiration of time of 0 (forever). This 1293 * is a limitation of the Memcached PECL extension. 1294 * 1295 * @link http://www.php.net/manual/en/memcached.get.php 1296 * 1297 * @param string $key The key under which to store the value. 1298 * @param string $group The group value appended to the $key. 1299 * @param bool $force Whether or not to force a cache invalidation. 1300 * @param null|bool $found Variable passed by reference to determine if the value was found or not. 1301 * @param string $server_key The key identifying the server to store the value on. 1302 * @param bool $by_key True to store in internal cache by key; false to not store by key 1303 * @param null|callable $cache_cb Read-through caching callback. 1304 * @param null|float $cas_token The variable to store the CAS token in. 1305 * @return bool|mixed Cached object value. 1293 * Retrieves object from cache. 1294 * 1295 * Gets an object from cache based on $key and $group. In order to fully support 1296 * the $cache_cb and $cas_token parameters, the runtime cache is ignored by this function 1297 * if either of those values are set. In that case, the request is made directly 1298 * to the memcached server for proper handling of the callback and/or token. 1299 * Note that the $cas_token variable cannot be directly passed to the function. 1300 * The variable needs to be first defined with a non-null value. 1301 * 1302 * If using the $cache_cb argument, the new value will always have an expiration 1303 * of time of 0 (forever). This is a limitation of the Memcached PECL extension. 1304 * 1305 * @link https://www.php.net/manual/en/memcached.get.php 1306 * 1307 * @param string $key The key under which to store the value. 1308 * @param string $group The group value appended to the $key. 1309 * @param bool $force Whether or not to force a cache invalidation. 1310 * @param null|bool $found Variable passed by reference to determine if the value was found or not. 1311 * @param string $server_key The key identifying the server to store the value on. 1312 * @param bool $by_key True to store in internal cache by key; false to not store by key. 1313 * @param null|callable $cache_cb Read-through caching callback. 1314 * @param null|float $cas_token The variable to store the CAS token in. 1315 * @return bool|mixed Cached object value. 1306 1316 */ 1307 1317 public function get( $key, $group = 'default', $force = false, &$found = null, $server_key = '', $by_key = false, $cache_cb = null, &$cas_token = null ) { 1308 1318 $derived_key = $this->buildKey( $key, $group ); 1309 1319 1310 // Assume object is not found 1320 // Assume object is not found. 1311 1321 $found = false; 1312 1322 1313 // If either $cache_db, or $cas_token is set, must hit Memcached and bypass runtime cache 1323 // If either $cache_db, or $cas_token is set, must hit Memcached and bypass runtime cache. 1314 1324 if ( func_num_args() > 6 && ! in_array( $group, $this->no_mc_groups, true ) ) { 1315 1325 if ( $by_key ) { … … 1342 1352 1343 1353 /** 1344 * Retrieve object from cache from specified server. 1345 * 1346 * Gets an object from cache based on $key, $group and $server_key. In order to fully support the $cache_cb and $cas_token 1347 * parameters, the runtime cache is ignored by this function if either of those values are set. If either of 1348 * those values are set, the request is made directly to the memcached server for proper handling of the 1349 * callback and/or token. Note that the $cas_token variable cannot be directly passed to the function. The 1350 * variable need to be first defined with a non null value. 1351 * 1352 * If using the $cache_cb argument, the new value will always have an expiration of time of 0 (forever). This 1353 * is a limitation of the Memcached PECL extension. 1354 * 1355 * @link http://www.php.net/manual/en/memcached.getbykey.php 1356 * 1357 * @param string $server_key The key identifying the server to store the value on. 1358 * @param string $key The key under which to store the value. 1359 * @param string $group The group value appended to the $key. 1360 * @param bool $force Whether or not to force a cache invalidation. 1361 * @param null|bool $found Variable passed by reference to determine if the value was found or not. 1362 * @param null|string $cache_cb Read-through caching callback. 1363 * @param null|float $cas_token The variable to store the CAS token in. 1364 * @return bool|mixed Cached object value. 1354 * Retrieves object from cache from specified server. 1355 * 1356 * Gets an object from cache based on $key and $group, and $server_key. In order to fully support 1357 * the $cache_cb and $cas_token parameters, the runtime cache is ignored by this function 1358 * if either of those values are set. In that case, the request is made directly 1359 * to the memcached server for proper handling of the callback and/or token. 1360 * Note that the $cas_token variable cannot be directly passed to the function. 1361 * The variable needs to be first defined with a non-null value. 1362 * 1363 * If using the $cache_cb argument, the new value will always have an expiration 1364 * of time of 0 (forever). This is a limitation of the Memcached PECL extension. 1365 * 1366 * @link https://www.php.net/manual/en/memcached.getbykey.php 1367 * 1368 * @param string $server_key The key identifying the server to store the value on. 1369 * @param string $key The key under which to store the value. 1370 * @param string $group The group value appended to the $key. 1371 * @param bool $force Whether or not to force a cache invalidation. 1372 * @param null|bool $found Variable passed by reference to determine if the value was found or not. 1373 * @param null|string $cache_cb Read-through caching callback. 1374 * @param null|float $cas_token The variable to store the CAS token in. 1375 * @return bool|mixed Cached object value. 1365 1376 */ 1366 1377 public function getByKey( $server_key, $key, $group = 'default', $force = false, &$found = null, $cache_cb = null, &$cas_token = null ) { … … 1377 1388 1378 1389 /** 1379 * Request multiple keys without blocking. 1380 * 1381 * @link http://www.php.net/manual/en/memcached.getdelayed.php 1382 * 1383 * @param string|array $keys Array or string of key(s) to request. 1384 * @param string|array $groups Array or string of group(s) for the key(s). See buildKeys for more on how these are handled. 1385 * @param bool $with_cas Whether to request CAS token values also. 1386 * @param null $value_cb The result callback or NULL. 1387 * @return bool Returns TRUE on success or FALSE on failure. 1390 * Requests multiple keys without blocking. 1391 * 1392 * @link https://www.php.net/manual/en/memcached.getdelayed.php 1393 * 1394 * @param string|array $keys Array or string of key(s) to request. 1395 * @param string|array $groups Array or string of group(s) for the key(s). 1396 * See buildKeys for more on how these are handled. 1397 * @param bool $with_cas Whether to request CAS token values also. 1398 * @param null $value_cb The result callback or null. 1399 * @return bool True on success, false on failure. 1388 1400 */ 1389 1401 public function getDelayed( $keys, $groups = 'default', $with_cas = false, $value_cb = null ) { … … 1393 1405 1394 1406 /** 1395 * Request multiple keys without blocking from a specified server. 1396 * 1397 * @link http://www.php.net/manual/en/memcached.getdelayed.php 1398 * 1399 * @param string $server_key The key identifying the server to store the value on. 1400 * @param string|array $keys Array or string of key(s) to request. 1401 * @param string|array $groups Array or string of group(s) for the key(s). See buildKeys for more on how these are handled. 1402 * @param bool $with_cas Whether to request CAS token values also. 1403 * @param null $value_cb The result callback or NULL. 1404 * @return bool Returns TRUE on success or FALSE on failure. 1407 * Requests multiple keys without blocking from a specified server. 1408 * 1409 * @link https://www.php.net/manual/en/memcached.getdelayed.php 1410 * 1411 * @param string $server_key The key identifying the server to store the value on. 1412 * @param string|array $keys Array or string of key(s) to request. 1413 * @param string|array $groups Array or string of group(s) for the key(s). 1414 * See buildKeys for more on how these are handled. 1415 * @param bool $with_cas Whether to request CAS token values also. 1416 * @param null $value_cb The result callback or null. 1417 * @return bool True on success, false on failure. 1405 1418 */ 1406 1419 public function getDelayedByKey( $server_key, $keys, $groups = 'default', $with_cas = false, $value_cb = null ) { … … 1414 1427 * See the buildKeys method definition to understand the $keys/$groups parameters. 1415 1428 * 1416 * @link http://www.php.net/manual/en/memcached.getmulti.php 1417 * 1418 * @param array $keys Array of keys to retrieve. 1419 * @param string|array $groups If string, used for all keys. If arrays, corresponds with the $keys array. 1420 * @param string $server_key The key identifying the server to store the value on. 1421 * @param null|array $cas_tokens The variable to store the CAS tokens for the found items. 1422 * @param int $flags The flags for the get operation. 1423 * @return bool|array Returns the array of found items or FALSE on failure. 1429 * @link https://www.php.net/manual/en/memcached.getmulti.php 1430 * 1431 * @param array $keys Array of keys to retrieve. 1432 * @param string|array $groups If string, used for all keys. 1433 * If arrays, corresponds with the $keys array. 1434 * @param string $server_key The key identifying the server to store the value on. 1435 * @param null|array $cas_tokens The variable to store the CAS tokens for the found items. 1436 * @param int $flags The flags for the get operation. 1437 * @return bool|array The array of found items on success, false on failure. 1424 1438 */ 1425 1439 public function getMulti( $keys, $groups = 'default', $server_key = '', &$cas_tokens = null, $flags = null ) { … … 1427 1441 1428 1442 /** 1429 * If either $cas_tokens, or $flags is set, must hit Memcached and bypass runtime cache. Note that1430 * this will purposely ignore no_mc_groups values as they cannot handle CAS tokens or the special1431 * flags; however, if the groups of groups contains a no_mc_group, this is bypassed.1443 * If either $cas_tokens, or $flags is set, must hit Memcached and bypass runtime cache. 1444 * Note that this will purposely ignore no_mc_groups values as they cannot handle CAS tokens 1445 * or the special flags; however, if the groups of groups contains a no_mc_group, this is bypassed. 1432 1446 */ 1433 1447 if ( func_num_args() > 3 && ! $this->contains_no_mc_group( $groups ) ) { … … 1441 1455 $need_to_get = array(); 1442 1456 1443 // Pull out values from runtime cache, or mark for retrieval 1457 // Pull out values from runtime cache, or mark for retrieval. 1444 1458 foreach ( $derived_keys as $key ) { 1445 1459 if ( isset( $this->cache[ $key ] ) ) { … … 1450 1464 } 1451 1465 1452 // Get those keys not found in the runtime cache 1466 // Get those keys not found in the runtime cache. 1453 1467 if ( ! empty( $need_to_get ) ) { 1454 1468 if ( ! empty( $server_key ) ) { … … 1459 1473 } 1460 1474 1461 // Merge with values found in runtime cache 1475 // Merge with values found in runtime cache. 1462 1476 if ( isset( $result ) && Memcached::RES_SUCCESS === $this->getResultCode() ) { 1463 1477 $values = array_merge( $values, $result ); 1464 1478 } 1465 1479 1466 // If order should be preserved, reorder now 1480 // If order should be preserved, reorder now. 1467 1481 if ( ! empty( $need_to_get ) && Memcached::GET_PRESERVE_ORDER === $flags ) { 1468 1482 $ordered_values = array(); … … 1479 1493 } 1480 1494 1481 // Add the values to the runtime cache 1495 // Add the values to the runtime cache. 1482 1496 $this->cache = array_merge( $this->cache, $values ); 1483 1497 … … 1490 1504 * See the buildKeys method definition to understand the $keys/$groups parameters. 1491 1505 * 1492 * @link http://www.php.net/manual/en/memcached.getmultibykey.php 1493 * 1494 * @param string $server_key The key identifying the server to store the value on. 1495 * @param array $keys Array of keys to retrieve. 1496 * @param string|array $groups If string, used for all keys. If arrays, corresponds with the $keys array. 1497 * @param null|array $cas_tokens The variable to store the CAS tokens for the found items. 1498 * @param int $flags The flags for the get operation. 1499 * @return bool|array Returns the array of found items or FALSE on failure. 1506 * @link https://www.php.net/manual/en/memcached.getmultibykey.php 1507 * 1508 * @param string $server_key The key identifying the server to store the value on. 1509 * @param array $keys Array of keys to retrieve. 1510 * @param string|array $groups If string, used for all keys. 1511 * If arrays, corresponds with the $keys array. 1512 * @param null|array $cas_tokens The variable to store the CAS tokens for the found items. 1513 * @param int $flags The flags for the get operation. 1514 * @return bool|array The array of found items on success, false on failure. 1500 1515 */ 1501 1516 public function getMultiByKey( $server_key, $keys, $groups = 'default', &$cas_tokens = null, $flags = null ) { … … 1512 1527 1513 1528 /** 1514 * Retrieve a Memcached option value.1515 * 1516 * @link http ://www.php.net/manual/en/memcached.getoption.php1517 * 1518 * @param int $optionOne of the Memcached::OPT_* constants.1519 * @return mixed Returns the value of the requested option, or FALSE on error.1529 * Retrieves a Memcached option value. 1530 * 1531 * @link https://www.php.net/manual/en/memcached.getoption.php 1532 * 1533 * @param int $option One of the Memcached::OPT_* constants. 1534 * @return mixed The value of the requested option on success, false on failure. 1520 1535 */ 1521 1536 public function getOption( $option ) { … … 1524 1539 1525 1540 /** 1526 * Return the result code of the last option.1527 * 1528 * @link http ://www.php.net/manual/en/memcached.getresultcode.php1529 * 1530 * @return intResult code of the last Memcached operation.1541 * Returns the result code of the last option. 1542 * 1543 * @link https://www.php.net/manual/en/memcached.getresultcode.php 1544 * 1545 * @return int Result code of the last Memcached operation. 1531 1546 */ 1532 1547 public function getResultCode() { … … 1537 1552 * Return the message describing the result of the last operation. 1538 1553 * 1539 * @link http://www.php.net/manual/en/memcached.getresultmessage.php1540 * 1541 * @return stringMessage describing the result of the last Memcached operation.1554 * @link https://www.php.net/manual/en/memcached.getresultmessage.php 1555 * 1556 * @return string Message describing the result of the last Memcached operation. 1542 1557 */ 1543 1558 public function getResultMessage() { … … 1546 1561 1547 1562 /** 1548 * Get server information by key.1549 * 1550 * @link http://www.php.net/manual/en/memcached.getserverbykey.php1551 * 1552 * @param string $server_keyThe key identifying the server to store the value on.1553 * @return array Array with host, post, and weight on success, FALSEon failure.1563 * Gets server information by key. 1564 * 1565 * @link https://www.php.net/manual/en/memcached.getserverbykey.php 1566 * 1567 * @param string $server_key The key identifying the server to store the value on. 1568 * @return array Array with host, post, and weight on success, false on failure. 1554 1569 */ 1555 1570 public function getServerByKey( $server_key ) { … … 1558 1573 1559 1574 /** 1560 * Get the list of servers in the pool.1561 * 1562 * @link http://www.php.net/manual/en/memcached.getserverlist.php1563 * 1564 * @return arrayThe list of all servers in the server pool.1575 * Gets the list of servers in the pool. 1576 * 1577 * @link https://www.php.net/manual/en/memcached.getserverlist.php 1578 * 1579 * @return array The list of all servers in the server pool. 1565 1580 */ 1566 1581 public function getServerList() { … … 1569 1584 1570 1585 /** 1571 * Get server pool statistics.1572 * 1573 * @link http://www.php.net/manual/en/memcached.getstats.php1574 * 1575 * @return arrayArray of server statistics, one entry per server.1586 * Gets server pool statistics. 1587 * 1588 * @link https://www.php.net/manual/en/memcached.getstats.php 1589 * 1590 * @return array Array of server statistics, one entry per server. 1576 1591 */ 1577 1592 public function getStats() { … … 1580 1595 1581 1596 /** 1582 * Get server pool memcached version information.1583 * 1584 * @link http://www.php.net/manual/en/memcached.getversion.php1585 * 1586 * @return arrayArray of server versions, one entry per server.1597 * Gets server pool memcached version information. 1598 * 1599 * @link https://www.php.net/manual/en/memcached.getversion.php 1600 * 1601 * @return array Array of server versions, one entry per server. 1587 1602 */ 1588 1603 public function getVersion() { … … 1591 1606 1592 1607 /** 1593 * Increment a numeric item's value.1594 * 1595 * @link http ://www.php.net/manual/en/memcached.increment.php1596 * 1597 * @param string $keyThe key under which to store the value.1598 * @param int $offsetThe amount by which to increment the item's value.1599 * @param string $groupThe group value appended to the $key.1600 * @return int|bool Returns item's new value on success or FALSEon failure.1608 * Increments a numeric item's value. 1609 * 1610 * @link https://www.php.net/manual/en/memcached.increment.php 1611 * 1612 * @param string $key The key under which to store the value. 1613 * @param int $offset The amount by which to increment the item's value. 1614 * @param string $group The group value appended to the $key. 1615 * @return int|bool Item's new value on success, false on failure. 1601 1616 */ 1602 1617 public function increment( $key, $offset = 1, $group = 'default' ) { 1603 1618 $derived_key = $this->buildKey( $key, $group ); 1604 1619 1605 // Increment values in no_mc_groups 1620 // Increment values in no_mc_groups. 1606 1621 if ( in_array( $group, $this->no_mc_groups, true ) ) { 1607 1622 1608 // Only increment if the key already exists and the number is currently 0 or greater (mimics memcached behavior) 1623 // Only increment if the key already exists and the number is currently 0 or greater (mimics memcached behavior). 1609 1624 if ( isset( $this->cache[ $derived_key ] ) && $this->cache[ $derived_key ] >= 0 ) { 1610 1625 1611 // If numeric, add; otherwise, consider it 0 and do nothing 1626 // If numeric, add; otherwise, consider it 0 and do nothing. 1612 1627 if ( is_numeric( $this->cache[ $derived_key ] ) ) { 1613 1628 $this->cache[ $derived_key ] += (int) $offset; … … 1616 1631 } 1617 1632 1618 // Returned value cannot be less than 0 1633 // Returned value cannot be less than 0. 1619 1634 if ( $this->cache[ $derived_key ] < 0 ) { 1620 1635 $this->cache[ $derived_key ] = 0; … … 1637 1652 1638 1653 /** 1639 * Synonymous with $this->incr. 1640 * 1641 * Certain plugins expect an "incr" method on the $wp_object_cache object (e.g., Batcache). Since the original 1642 * version of this library matched names to the memcached methods, the "incr" method was missing. Adding this 1643 * method restores compatibility with plugins expecting an "incr" method. 1644 * 1645 * @param string $key The key under which to store the value. 1646 * @param int $offset The amount by which to increment the item's value. 1647 * @param string $group The group value appended to the $key. 1648 * @return int|bool Returns item's new value on success or FALSE on failure. 1654 * Alias for $this->incr(). 1655 * 1656 * Certain plugins expect an "incr" method on the $wp_object_cache object (e.g., Batcache). 1657 * Since the original version of this library matched names to the memcached methods, 1658 * the "incr" method was missing. Adding this method restores compatibility with plugins 1659 * expecting an "incr" method. 1660 * 1661 * @param string $key The key under which to store the value. 1662 * @param int $offset The amount by which to increment the item's value. 1663 * @param string $group The group value appended to the $key. 1664 * @return int|bool Item's new value on success, false on failure. 1649 1665 */ 1650 1666 public function incr( $key, $offset = 1, $group = 'default' ) { … … 1653 1669 1654 1670 /** 1655 * Prepend data to an existing item.1671 * Prepends data to an existing item. 1656 1672 * 1657 1673 * This method should throw an error if it is used with compressed data. This is an expected behavior. 1658 * Memcached casts the value to be prepended to the initial value to the type of the initial value. Be1659 * careful as this leads to unexpected behavior at times. For instance, prepending (float) 45.23 to1660 * (int) 23 will result in 45, because the value is first combined (45.2323) then cast to "integer"1674 * Memcached casts the value to be prepended to the initial value to the type of the initial value. 1675 * Be careful as this leads to unexpected behavior at times. For instance, prepending (float) 45.23 1676 * to (int) 23 will result in 45, because the value is first combined (45.2323) then cast to "integer" 1661 1677 * (the original value), which will be (int) 45. Due to how memcached treats types, the behavior has been 1662 * mimicked in the internal cache to produce similar results and improve consistency. It is recommend 1678 * mimicked in the internal cache to produce similar results and improve consistency. It is recommended 1663 1679 * that prepends only occur with data of the same type. 1664 1680 * 1665 * @link http://www.php.net/manual/en/memcached.prepend.php1666 * 1667 * @param string $keyThe key under which to store the value.1668 * @param string $valueMust be string as prepending mixed values is not well-defined.1669 * @param string $groupThe group value prepended to the $key.1670 * @param string $server_keyThe key identifying the server to store the value on.1671 * @param bool $by_key True to store in internal cache by key; false to not store by key1672 * @return bool Returns TRUE on success or FALSEon failure.1681 * @link https://www.php.net/manual/en/memcached.prepend.php 1682 * 1683 * @param string $key The key under which to store the value. 1684 * @param string $value Must be string as prepending mixed values is not well-defined. 1685 * @param string $group The group value prepended to the $key. 1686 * @param string $server_key The key identifying the server to store the value on. 1687 * @param bool $by_key True to store in internal cache by key; false to not store by key. 1688 * @return bool True on success, false on failure. 1673 1689 */ 1674 1690 public function prepend( $key, $value, $group = 'default', $server_key = '', $by_key = false ) { … … 1679 1695 $derived_key = $this->buildKey( $key, $group ); 1680 1696 1681 // If group is a non-Memcached group, prepend to runtime cache value, not Memcached 1697 // If group is a non-Memcached group, prepend to runtime cache value, not Memcached. 1682 1698 if ( in_array( $group, $this->no_mc_groups, true ) ) { 1683 1699 if ( ! isset( $this->cache[ $derived_key ] ) ) { … … 1690 1706 } 1691 1707 1692 // Append to Memcached value 1708 // Append to Memcached value. 1693 1709 if ( $by_key ) { 1694 1710 $result = $this->m->prependByKey( $server_key, $derived_key, $value ); … … 1697 1713 } 1698 1714 1699 // Store in runtime cache if add was successful 1715 // Store in runtime cache if add was successful. 1700 1716 if ( Memcached::RES_SUCCESS === $this->getResultCode() ) { 1701 1717 $combined = $this->combine_values( $this->cache[ $derived_key ], $value, 'pre' ); … … 1707 1723 1708 1724 /** 1709 * Append data to an existing item by server key.1725 * Appends data to an existing item by server key. 1710 1726 * 1711 1727 * This method should throw an error if it is used with compressed data. This is an expected behavior. 1712 * Memcached casts the value to be prepended to the initial value to the type of the initial value. Be1713 * careful as this leads to unexpected behavior at times. For instance, prepending (float) 45.23 to1714 * (int) 23 will result in 45, because the value is first combined (45.2323) then cast to "integer"1728 * Memcached casts the value to be prepended to the initial value to the type of the initial value. 1729 * Be careful as this leads to unexpected behavior at times. For instance, prepending (float) 45.23 1730 * to (int) 23 will result in 45, because the value is first combined (45.2323) then cast to "integer" 1715 1731 * (the original value), which will be (int) 45. Due to how memcached treats types, the behavior has been 1716 * mimicked in the internal cache to produce similar results and improve consistency. It is recommend 1732 * mimicked in the internal cache to produce similar results and improve consistency. It is recommended 1717 1733 * that prepends only occur with data of the same type. 1718 1734 * 1719 * @link http://www.php.net/manual/en/memcached.prependbykey.php1720 * 1721 * @param string $server_keyThe key identifying the server to store the value on.1722 * @param string $keyThe key under which to store the value.1723 * @param string $valueMust be string as prepending mixed values is not well-defined.1724 * @param string $groupThe group value prepended to the $key.1725 * @return bool Returns TRUE on success or FALSEon failure.1735 * @link https://www.php.net/manual/en/memcached.prependbykey.php 1736 * 1737 * @param string $server_key The key identifying the server to store the value on. 1738 * @param string $key The key under which to store the value. 1739 * @param string $value Must be string as prepending mixed values is not well-defined. 1740 * @param string $group The group value prepended to the $key. 1741 * @return bool True on success, false on failure. 1726 1742 */ 1727 1743 public function prependByKey( $server_key, $key, $value, $group = 'default' ) { … … 1732 1748 * Replaces a value in cache. 1733 1749 * 1734 * This method is similar to "add"; however, is does not successfully set a value if1735 * the object's key is not already set in cache.1736 * 1737 * @link http://www.php.net/manual/en/memcached.replace.php1738 * 1739 * @param string $server_keyThe key identifying the server to store the value on.1740 * @param string $keyThe key under which to store the value.1741 * @param mixed $valueThe value to store.1742 * @param string $groupThe group value appended to the $key.1743 * @param bool $by_key True to store in internal cache by key; false to not store by key1744 * @param int $expirationThe expiration time, defaults to 0.1745 * @return bool Returns TRUE on success or FALSEon failure.1750 * This method is similar to "add"; however, is does not successfully set a value 1751 * if the object's key is not already set in cache. 1752 * 1753 * @link https://www.php.net/manual/en/memcached.replace.php 1754 * 1755 * @param string $server_key The key identifying the server to store the value on. 1756 * @param string $key The key under which to store the value. 1757 * @param mixed $value The value to store. 1758 * @param string $group The group value appended to the $key. 1759 * @param bool $by_key True to store in internal cache by key; false to not store by key. 1760 * @param int $expiration The expiration time, defaults to 0. 1761 * @return bool True on success, false on failure. 1746 1762 */ 1747 1763 public function replace( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by_key = false ) { … … 1749 1765 $expiration = $this->sanitize_expiration( $expiration ); 1750 1766 1751 // If group is a non-Memcached group, save to runtime cache, not Memcached 1767 // If group is a non-Memcached group, save to runtime cache, not Memcached. 1752 1768 if ( in_array( $group, $this->no_mc_groups, true ) ) { 1753 1769 1754 // Replace won't save unless the key already exists; mimic this behavior here 1770 // Replace won't save unless the key already exists; mimic this behavior here. 1755 1771 if ( ! isset( $this->cache[ $derived_key ] ) ) { 1756 1772 return false; … … 1761 1777 } 1762 1778 1763 // Save to Memcached 1779 // Save to Memcached. 1764 1780 if ( $by_key ) { 1765 1781 $result = $this->m->replaceByKey( $server_key, $derived_key, $value, $expiration ); … … 1768 1784 } 1769 1785 1770 // Store in runtime cache if add was successful 1786 // Store in runtime cache if add was successful. 1771 1787 if ( Memcached::RES_SUCCESS === $this->getResultCode() ) { 1772 1788 $this->add_to_internal_cache( $derived_key, $value ); … … 1779 1795 * Replaces a value in cache on a specific server. 1780 1796 * 1781 * This method is similar to "addByKey"; however, is does not successfully set a value if1782 * the object's key is not already set in cache.1783 * 1784 * @link http://www.php.net/manual/en/memcached.addbykey.php1785 * 1786 * @param string $server_keyThe key identifying the server to store the value on.1787 * @param string $keyThe key under which to store the value.1788 * @param mixed $valueThe value to store.1789 * @param string $groupThe group value appended to the $key.1790 * @param int $expirationThe expiration time, defaults to 0.1791 * @return bool Returns TRUE on success or FALSEon failure.1797 * This method is similar to "addByKey"; however, is does not successfully set a value 1798 * if the object's key is not already set in cache. 1799 * 1800 * @link https://www.php.net/manual/en/memcached.addbykey.php 1801 * 1802 * @param string $server_key The key identifying the server to store the value on. 1803 * @param string $key The key under which to store the value. 1804 * @param mixed $value The value to store. 1805 * @param string $group The group value appended to the $key. 1806 * @param int $expiration The expiration time, defaults to 0. 1807 * @return bool True on success, false on failure. 1792 1808 */ 1793 1809 public function replaceByKey( $server_key, $key, $value, $group = 'default', $expiration = 0 ) { … … 1800 1816 * The value is set whether or not this key already exists in memcached. 1801 1817 * 1802 * @link http ://www.php.net/manual/en/memcached.set.php1803 * 1804 * @param string$key The key under which to store the value.1805 * @param mixed$value The value to store.1806 * @param string$group The group value appended to the $key.1807 * @param int$expiration The expiration time, defaults to 0.1808 * @param string$server_key The key identifying the server to store the value on.1809 * @param bool $by_key True to store in internal cache by key; false to not store by key1810 * @return bool Returns TRUE on success or FALSEon failure.1818 * @link https://www.php.net/manual/en/memcached.set.php 1819 * 1820 * @param string $key The key under which to store the value. 1821 * @param mixed $value The value to store. 1822 * @param string $group The group value appended to the $key. 1823 * @param int $expiration The expiration time, defaults to 0. 1824 * @param string $server_key The key identifying the server to store the value on. 1825 * @param bool $by_key True to store in internal cache by key; false to not store by key. 1826 * @return bool True on success, false on failure. 1811 1827 */ 1812 1828 public function set( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by_key = false ) { … … 1814 1830 $expiration = $this->sanitize_expiration( $expiration ); 1815 1831 1816 // If group is a non-Memcached group, save to runtime cache, not Memcached 1832 // If group is a non-Memcached group, save to runtime cache, not Memcached. 1817 1833 if ( in_array( $group, $this->no_mc_groups, true ) ) { 1818 1834 $this->add_to_internal_cache( $derived_key, $value ); … … 1820 1836 } 1821 1837 1822 // Save to Memcached 1838 // Save to Memcached. 1823 1839 if ( $by_key ) { 1824 1840 $result = $this->m->setByKey( $server_key, $derived_key, $value, $expiration ); … … 1827 1843 } 1828 1844 1829 // Store in runtime cache if add was successful 1845 // Store in runtime cache if add was successful. 1830 1846 if ( Memcached::RES_SUCCESS === $this->getResultCode() ) { 1831 1847 $this->add_to_internal_cache( $derived_key, $value ); … … 1840 1856 * The value is set whether or not this key already exists in memcached. 1841 1857 * 1842 * @link http://www.php.net/manual/en/memcached.setbykey.php1843 * 1844 * @param string $server_keyThe key identifying the server to store the value on.1845 * @param string $keyThe key under which to store the value.1846 * @param mixed $valueThe value to store.1847 * @param string $groupThe group value appended to the $key.1848 * @param int $expirationThe expiration time, defaults to 0.1849 * @return bool Returns TRUE on success or FALSEon failure.1858 * @link https://www.php.net/manual/en/memcached.setbykey.php 1859 * 1860 * @param string $server_key The key identifying the server to store the value on. 1861 * @param string $key The key under which to store the value. 1862 * @param mixed $value The value to store. 1863 * @param string $group The group value appended to the $key. 1864 * @param int $expiration The expiration time, defaults to 0. 1865 * @return bool True on success, false on failure. 1850 1866 */ 1851 1867 public function setByKey( $server_key, $key, $value, $group = 'default', $expiration = 0 ) { … … 1854 1870 1855 1871 /** 1856 * Set multiple values to cache at once.1872 * Sets multiple values to cache at once. 1857 1873 * 1858 1874 * By sending an array of $items to this function, all values are saved at once to … … 1862 1878 * final key for the object. 1863 1879 * 1864 * @link http://www.php.net/manual/en/memcached.setmulti.php1865 * 1866 * @param array $itemsAn array of key/value pairs to store on the server.1867 * @param string|array $groupsGroup(s) to merge with key(s) in $items.1868 * @param int $expirationThe expiration time, defaults to 0.1869 * @param string $server_keyThe key identifying the server to store the value on.1870 * @param bool $by_key True to store in internal cache by key; false to not store by key1871 * @return bool Returns TRUE on success or FALSEon failure.1880 * @link https://www.php.net/manual/en/memcached.setmulti.php 1881 * 1882 * @param array $items An array of key/value pairs to store on the server. 1883 * @param string|array $groups Group(s) to merge with key(s) in $items. 1884 * @param int $expiration The expiration time, defaults to 0. 1885 * @param string $server_key The key identifying the server to store the value on. 1886 * @param bool $by_key True to store in internal cache by key; false to not store by key. 1887 * @return bool True on success, false on failure. 1872 1888 */ 1873 1889 public function setMulti( $items, $groups = 'default', $expiration = 0, $server_key = '', $by_key = false ) { 1874 // Build final keys and replace $items keys with the new keys 1890 // Build final keys and replace $items keys with the new keys. 1875 1891 $derived_keys = $this->buildKeys( array_keys( $items ), $groups ); 1876 1892 $expiration = $this->sanitize_expiration( $expiration ); 1877 1893 $derived_items = array_combine( $derived_keys, $items ); 1878 1894 1879 // Do not add to memcached if in no_mc_groups 1895 // Do not add to memcached if in no_mc_groups. 1880 1896 foreach ( $derived_items as $derived_key => $value ) { 1881 1897 1882 // Get the individual item's group 1898 // Get the individual item's group. 1883 1899 $key_pieces = explode( ':', $derived_key ); 1884 1900 1885 // If group is a non-Memcached group, save to runtime cache, not Memcached 1901 // If group is a non-Memcached group, save to runtime cache, not Memcached. 1886 1902 if ( in_array( $key_pieces[1], $this->no_mc_groups, true ) ) { 1887 1903 $this->add_to_internal_cache( $derived_key, $value ); … … 1890 1906 } 1891 1907 1892 // Save to memcached 1908 // Save to memcached. 1893 1909 if ( $by_key ) { 1894 1910 $result = $this->m->setMultiByKey( $server_key, $derived_items, $expiration ); … … 1897 1913 } 1898 1914 1899 // Store in runtime cache if add was successful 1915 // Store in runtime cache if add was successful. 1900 1916 if ( Memcached::RES_SUCCESS === $this->getResultCode() ) { 1901 1917 $this->cache = array_merge( $this->cache, $derived_items ); … … 1906 1922 1907 1923 /** 1908 * Set multiple values to cache at once on specified server.1924 * Sets multiple values to cache at once on specified server. 1909 1925 * 1910 1926 * By sending an array of $items to this function, all values are saved at once to … … 1914 1930 * final key for the object. 1915 1931 * 1916 * @link http://www.php.net/manual/en/memcached.setmultibykey.php1917 * 1918 * @param string $server_keyThe key identifying the server to store the value on.1919 * @param array $itemsAn array of key/value pairs to store on the server.1920 * @param string|array $groupsGroup(s) to merge with key(s) in $items.1921 * @param int $expirationThe expiration time, defaults to 0.1922 * @return bool Returns TRUE on success or FALSEon failure.1932 * @link https://www.php.net/manual/en/memcached.setmultibykey.php 1933 * 1934 * @param string $server_key The key identifying the server to store the value on. 1935 * @param array $items An array of key/value pairs to store on the server. 1936 * @param string|array $groups Group(s) to merge with key(s) in $items. 1937 * @param int $expiration The expiration time, defaults to 0. 1938 * @return bool True on success, false on failure. 1923 1939 */ 1924 1940 public function setMultiByKey( $server_key, $items, $groups = 'default', $expiration = 0 ) { … … 1927 1943 1928 1944 /** 1929 * Set a Memcached option.1930 * 1931 * @link http://www.php.net/manual/en/memcached.setoption.php1932 * 1933 * @param int $optionOption name.1934 * @param mixed $valueOption value.1935 * @return bool Returns TRUE on success or FALSEon failure.1945 * Sets a Memcached option. 1946 * 1947 * @link https://www.php.net/manual/en/memcached.setoption.php 1948 * 1949 * @param int $option Option name. 1950 * @param mixed $value Option value. 1951 * @return bool True on success, false on failure. 1936 1952 */ 1937 1953 public function setOption( $option, $value ) { … … 1942 1958 * Builds a key for the cached object using the blog_id, key, and group values. 1943 1959 * 1944 * @author Ryan Boren This function is inspired by the original WP Memcached Object cache. 1945 * @link http://wordpress.org/extend/plugins/memcached/ 1946 * 1947 * @param string $key The key under which to store the value. 1948 * @param string $group The group value appended to the $key. 1949 * @return string 1960 * This function is inspired by the original WP Memcached Object cache. 1961 * 1962 * @author Ryan Boren 1963 * @link http://wordpress.org/extend/plugins/memcached/ 1964 * 1965 * @param string $key The key under which to store the value. 1966 * @param string $group The group value appended to the $key. 1967 * @return string 1950 1968 */ 1951 1969 public function buildKey( $key, $group = 'default' ) { … … 1975 1993 * that call memcached with an array of keys. 1976 1994 * 1977 * @param string|array $keysKey(s) to merge with group(s).1978 * @param string|array $groupsGroup(s) to merge with key(s).1979 * @return arrayArray that combines keys and groups into a single set of memcached keys.1995 * @param string|array $keys Key(s) to merge with group(s). 1996 * @param string|array $groups Group(s) to merge with key(s). 1997 * @return array Array that combines keys and groups into a single set of memcached keys. 1980 1998 */ 1981 1999 public function buildKeys( $keys, $groups = 'default' ) { 1982 2000 $derived_keys = array(); 1983 2001 1984 // If strings sent, convert to arrays for proper handling 2002 // If strings sent, convert to arrays for proper handling. 1985 2003 if ( ! is_array( $groups ) ) { 1986 2004 $groups = (array) $groups; … … 1991 2009 } 1992 2010 1993 // If we have equal numbers of keys and groups, merge $keys[n] and $group[n] 2011 // If we have equal numbers of keys and groups, merge $keys[n] and $group[n]. 1994 2012 if ( count( $keys ) === count( $groups ) ) { 1995 2013 for ( $i = 0; $i < count( $keys ); $i++ ) { … … 1997 2015 } 1998 2016 1999 // If more keys are received than groups, merge $keys[n] and $group[n] until no more group are left; remaining groups are 'default' 2017 // If more keys are received than groups, merge $keys[n] and $group[n] 2018 // until no more groups are left; remaining groups are 'default'. 2000 2019 } elseif ( count( $keys ) > count( $groups ) ) { 2001 2020 for ( $i = 0; $i < count( $keys ); $i++ ) { … … 2014 2033 2015 2034 /** 2016 * Ensure that a proper expiration time is set.2017 * 2018 * Memcached treats any value over 30 days as a timestamp. If a developer sets the expiration for greater than 302019 * days or less than the current timestamp, the timestamp is in the past and the value isn't cached. This function2020 * detects values in that range and corrects them.2021 * 2022 * @param string|int $expirationThe dirty expiration time.2023 * @return string|int 2035 * Ensures that a proper expiration time is set. 2036 * 2037 * Memcached treats any value over 30 days as a timestamp. If a developer sets the expiration 2038 * for greater than 30 days or less than the current timestamp, the timestamp is in the past 2039 * and the value isn't cached. This function detects values in that range and corrects them. 2040 * 2041 * @param string|int $expiration The dirty expiration time. 2042 * @return string|int The sanitized expiration time. 2024 2043 */ 2025 2044 public function sanitize_expiration( $expiration ) { … … 2038 2057 * will dictate the type of the combined value. 2039 2058 * 2040 * @param mixed $originalOriginal value that dictates the combined type.2041 * @param mixed $pendedValue to combine with original value.2042 * @param string $directionEither 'pre' or 'app'.2043 * @return mixedCombined value casted to the type of the first value.2059 * @param mixed $original Original value that dictates the combined type. 2060 * @param mixed $pended Value to combine with original value. 2061 * @param string $direction Either 'pre' or 'app'. 2062 * @return mixed Combined value casted to the type of the first value. 2044 2063 */ 2045 2064 public function combine_values( $original, $pended, $direction ) { 2046 2065 $type = gettype( $original ); 2047 2066 2048 // Combine the values based on direction of the "pend" 2067 // Combine the values based on direction of the "pend". 2049 2068 if ( 'pre' === $direction ) { 2050 2069 $combined = $pended . $original; … … 2053 2072 } 2054 2073 2055 // Cast type of combined value 2074 // Cast type of combined value. 2056 2075 settype( $combined, $type ); 2057 2076 … … 2062 2081 * Simple wrapper for saving object to the internal cache. 2063 2082 * 2064 * @param string $derived_keyKey to save value under.2065 * @param mixed $valueObject value.2083 * @param string $derived_key Key to save value under. 2084 * @param mixed $value Object value. 2066 2085 */ 2067 2086 public function add_to_internal_cache( $derived_key, $value ) { … … 2076 2095 * Determines if a no_mc_group exists in a group of groups. 2077 2096 * 2078 * @param mixed $groupsThe groups to search.2079 * @return boolTrue if a no_mc_group is present; false if a no_mc_group is not present.2097 * @param mixed $groups The groups to search. 2098 * @return bool True if a no_mc_group is present; false if a no_mc_group is not present. 2080 2099 */ 2081 2100 public function contains_no_mc_group( $groups ) { … … 2098 2117 2099 2118 /** 2100 * Add global groups. 2101 * 2102 * @author Ryan Boren This function comes straight from the original WP Memcached Object cache 2103 * @link http://wordpress.org/extend/plugins/memcached/ 2104 * 2105 * @param array $groups Array of groups. 2106 * @return void 2119 * Adds global groups. 2120 * 2121 * This function comes straight from the original WP Memcached Object cache. 2122 * 2123 * @author Ryan Boren 2124 * @link http://wordpress.org/extend/plugins/memcached/ 2125 * 2126 * @param array $groups Array of groups. 2127 * @return void 2107 2128 */ 2108 2129 public function add_global_groups( $groups ) { … … 2116 2137 2117 2138 /** 2118 * Add non-persistent groups. 2119 * 2120 * @author Ryan Boren This function comes straight from the original WP Memcached Object cache 2121 * @link http://wordpress.org/extend/plugins/memcached/ 2122 * 2123 * @param array $groups Array of groups. 2124 * @return void 2139 * Adds non-persistent groups. 2140 * 2141 * This function comes straight from the original WP Memcached Object cache. 2142 * 2143 * @author Ryan Boren 2144 * @link http://wordpress.org/extend/plugins/memcached/ 2145 * 2146 * @param array $groups Array of groups. 2147 * @return void 2125 2148 */ 2126 2149 public function add_non_persistent_groups( $groups ) { … … 2134 2157 2135 2158 /** 2136 * Get a value specifically from the internal, run-time cache, not memcached.2137 * 2138 * @param int|string $keyKey value.2139 * @param int|string $groupGroup that the value belongs to.2140 * @return bool|mixed Value on success;false on failure.2159 * Gets a value specifically from the internal, run-time cache, not memcached. 2160 * 2161 * @param int|string $key Key value. 2162 * @param int|string $group Group that the value belongs to. 2163 * @return bool|mixed Value on success, false on failure. 2141 2164 */ 2142 2165 public function get_from_runtime_cache( $key, $group ) { … … 2151 2174 2152 2175 /** 2153 * Switch blog prefix, which changes the cache that is accessed.2154 * 2155 * @param int $blog_idBlog to switch to.2176 * Switches blog prefix, which changes the cache that is accessed. 2177 * 2178 * @param int $blog_id Blog to switch to. 2156 2179 * @return void 2157 2180 */
Note: See TracChangeset
for help on using the changeset viewer.