KeyValueStoreExpirableInterface.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. * @param string $key
  22. * The key of the data to store.
  23. * @param mixed $value
  24. * The data to store.
  25. * @param int $expire
  26. * The time to live for items, in seconds.
  27. *
  28. * @return bool
  29. * TRUE if the data was set, or FALSE if it already existed.
  30. */
  31. public function setWithExpireIfNotExists($key, $value, $expire);
  32. /**
  33. * Saves an array of values with a time to live.
  34. *
  35. * @param array $data
  36. * An array of data to store.
  37. * @param int $expire
  38. * The time to live for items, in seconds.
  39. */
  40. public function setMultipleWithExpire(array $data, $expire);
  41. }