[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 3 // SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue 4 // SPDX-License-Identifier: BSD-3-Clause 5 6 declare(strict_types=1); 7 8 namespace SimplePie\Cache; 9 10 use InvalidArgumentException; 11 12 /** 13 * Subset of PSR-16 Cache client for caching data arrays 14 * 15 * Only get(), set() and delete() methods are used, 16 * but not has(), getMultiple(), setMultiple() or deleteMultiple(). 17 * 18 * The methods names must be different, but should be compatible to the 19 * methods of \Psr\SimpleCache\CacheInterface. 20 * 21 * @internal 22 */ 23 interface DataCache 24 { 25 /** 26 * Fetches a value from the cache. 27 * 28 * Equivalent to \Psr\SimpleCache\CacheInterface::get() 29 * <code> 30 * public function get(string $key, mixed $default = null): mixed; 31 * </code> 32 * 33 * @param string $key The unique key of this item in the cache. 34 * @param mixed $default Default value to return if the key does not exist. 35 * 36 * @return array|mixed The value of the item from the cache, or $default in case of cache miss. 37 * 38 * @throws InvalidArgumentException 39 * MUST be thrown if the $key string is not a legal value. 40 */ 41 public function get_data(string $key, $default = null); 42 43 /** 44 * Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time. 45 * 46 * Equivalent to \Psr\SimpleCache\CacheInterface::set() 47 * <code> 48 * public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool; 49 * </code> 50 * 51 * @param string $key The key of the item to store. 52 * @param array<mixed> $value The value of the item to store, must be serializable. 53 * @param null|int $ttl Optional. The TTL value of this item. If no value is sent and 54 * the driver supports TTL then the library may set a default value 55 * for it or let the driver take care of that. 56 * 57 * @return bool True on success and false on failure. 58 * 59 * @throws InvalidArgumentException 60 * MUST be thrown if the $key string is not a legal value. 61 */ 62 public function set_data(string $key, array $value, ?int $ttl = null): bool; 63 64 /** 65 * Delete an item from the cache by its unique key. 66 * 67 * Equivalent to \Psr\SimpleCache\CacheInterface::delete() 68 * <code> 69 * public function delete(string $key): bool; 70 * </code> 71 * 72 * @param string $key The unique cache key of the item to delete. 73 * 74 * @return bool True if the item was successfully removed. False if there was an error. 75 * 76 * @throws InvalidArgumentException 77 * MUST be thrown if the $key string is not a legal value. 78 */ 79 public function delete_data(string $key): bool; 80 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Fri Oct 10 08:20:03 2025 | Cross-referenced by PHPXref |