KeyValueStoreExpirableInterface.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Drupal\Core\KeyValueStore;
  3. /**
  4. * Defines the interface for expiring data in a key/value store.
  5. */
  6. interface KeyValueStoreExpirableInterface extends KeyValueStoreInterface {
  7. /**
  8. * Saves a value for a given key with a time to live.
  9. *
  10. * @param string $key
  11. * The key of the data to store.
  12. * @param mixed $value
  13. * The data to store.
  14. * @param int $expire
  15. * The time to live for items, in seconds.
  16. */
  17. public function setWithExpire($key, $value, $expire);
  18. /**
  19. * Sets a value for a given key with a time to live if it does not yet exist.
  20. *
  21. * If a key is expired it also does not exists.
  22. *
  23. * @param string $key
  24. * The key of the data to store.
  25. * @param mixed $value
  26. * The data to store.
  27. * @param int $expire
  28. * The time to live for items, in seconds.
  29. *
  30. * @return bool
  31. * TRUE if the data was set, or FALSE if it already existed.
  32. */
  33. public function setWithExpireIfNotExists($key, $value, $expire);
  34. /**
  35. * Saves an array of values with a time to live.
  36. *
  37. * @param array $data
  38. * An array of data to store.
  39. * @param int $expire
  40. * The time to live for items, in seconds.
  41. */
  42. public function setMultipleWithExpire(array $data, $expire);
  43. }