[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/php-ai-client/third-party/Psr/SimpleCache/ -> CacheInterface.php (source)

   1  <?php
   2  
   3  namespace WordPress\AiClientDependencies\Psr\SimpleCache;
   4  
   5  interface CacheInterface
   6  {
   7      /**
   8       * Fetches a value from the cache.
   9       *
  10       * @param string $key     The unique key of this item in the cache.
  11       * @param mixed  $default Default value to return if the key does not exist.
  12       *
  13       * @return mixed The value of the item from the cache, or $default in case of cache miss.
  14       *
  15       * @throws \Psr\SimpleCache\InvalidArgumentException
  16       *   MUST be thrown if the $key string is not a legal value.
  17       */
  18      public function get($key, $default = null);
  19      /**
  20       * Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
  21       *
  22       * @param string                 $key   The key of the item to store.
  23       * @param mixed                  $value The value of the item to store, must be serializable.
  24       * @param null|int|\DateInterval $ttl   Optional. The TTL value of this item. If no value is sent and
  25       *                                      the driver supports TTL then the library may set a default value
  26       *                                      for it or let the driver take care of that.
  27       *
  28       * @return bool True on success and false on failure.
  29       *
  30       * @throws \Psr\SimpleCache\InvalidArgumentException
  31       *   MUST be thrown if the $key string is not a legal value.
  32       */
  33      public function set($key, $value, $ttl = null);
  34      /**
  35       * Delete an item from the cache by its unique key.
  36       *
  37       * @param string $key The unique cache key of the item to delete.
  38       *
  39       * @return bool True if the item was successfully removed. False if there was an error.
  40       *
  41       * @throws \Psr\SimpleCache\InvalidArgumentException
  42       *   MUST be thrown if the $key string is not a legal value.
  43       */
  44      public function delete($key);
  45      /**
  46       * Wipes clean the entire cache's keys.
  47       *
  48       * @return bool True on success and false on failure.
  49       */
  50      public function clear();
  51      /**
  52       * Obtains multiple cache items by their unique keys.
  53       *
  54       * @param iterable $keys    A list of keys that can obtained in a single operation.
  55       * @param mixed    $default Default value to return for keys that do not exist.
  56       *
  57       * @return iterable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value.
  58       *
  59       * @throws \Psr\SimpleCache\InvalidArgumentException
  60       *   MUST be thrown if $keys is neither an array nor a Traversable,
  61       *   or if any of the $keys are not a legal value.
  62       */
  63      public function getMultiple($keys, $default = null);
  64      /**
  65       * Persists a set of key => value pairs in the cache, with an optional TTL.
  66       *
  67       * @param iterable               $values A list of key => value pairs for a multiple-set operation.
  68       * @param null|int|\DateInterval $ttl    Optional. The TTL value of this item. If no value is sent and
  69       *                                       the driver supports TTL then the library may set a default value
  70       *                                       for it or let the driver take care of that.
  71       *
  72       * @return bool True on success and false on failure.
  73       *
  74       * @throws \Psr\SimpleCache\InvalidArgumentException
  75       *   MUST be thrown if $values is neither an array nor a Traversable,
  76       *   or if any of the $values are not a legal value.
  77       */
  78      public function setMultiple($values, $ttl = null);
  79      /**
  80       * Deletes multiple cache items in a single operation.
  81       *
  82       * @param iterable $keys A list of string-based keys to be deleted.
  83       *
  84       * @return bool True if the items were successfully removed. False if there was an error.
  85       *
  86       * @throws \Psr\SimpleCache\InvalidArgumentException
  87       *   MUST be thrown if $keys is neither an array nor a Traversable,
  88       *   or if any of the $keys are not a legal value.
  89       */
  90      public function deleteMultiple($keys);
  91      /**
  92       * Determines whether an item is present in the cache.
  93       *
  94       * NOTE: It is recommended that has() is only to be used for cache warming type purposes
  95       * and not to be used within your live applications operations for get/set, as this method
  96       * is subject to a race condition where your has() will return true and immediately after,
  97       * another script can remove it making the state of your app out of date.
  98       *
  99       * @param string $key The cache item key.
 100       *
 101       * @return bool
 102       *
 103       * @throws \Psr\SimpleCache\InvalidArgumentException
 104       *   MUST be thrown if the $key string is not a legal value.
 105       */
 106      public function has($key);
 107  }


Generated : Sat Jun 13 09:38:55 2026 Cross-referenced by PHPXref