KeyValueStoreExpirableInterface.php

Same filename in other branches
  1. 9 core/lib/Drupal/Core/KeyValueStore/KeyValueStoreExpirableInterface.php
  2. 10 core/lib/Drupal/Core/KeyValueStore/KeyValueStoreExpirableInterface.php
  3. 11.x core/lib/Drupal/Core/KeyValueStore/KeyValueStoreExpirableInterface.php

Namespace

Drupal\Core\KeyValueStore

File

core/lib/Drupal/Core/KeyValueStore/KeyValueStoreExpirableInterface.php

View source
<?php

namespace Drupal\Core\KeyValueStore;


/**
 * Defines the interface for expiring data in a key/value store.
 */
interface KeyValueStoreExpirableInterface extends KeyValueStoreInterface {
    
    /**
     * Saves a value for a given key with a time to live.
     *
     * @param string $key
     *   The key of the data to store.
     * @param mixed $value
     *   The data to store.
     * @param int $expire
     *   The time to live for items, in seconds.
     */
    public function setWithExpire($key, $value, $expire);
    
    /**
     * Sets a value for a given key with a time to live if it does not yet exist.
     *
     * If a key is expired it also does not exists.
     *
     * @param string $key
     *   The key of the data to store.
     * @param mixed $value
     *   The data to store.
     * @param int $expire
     *   The time to live for items, in seconds.
     *
     * @return bool
     *   TRUE if the data was set, or FALSE if it already existed.
     */
    public function setWithExpireIfNotExists($key, $value, $expire);
    
    /**
     * Saves an array of values with a time to live.
     *
     * @param array $data
     *   An array of data to store.
     * @param int $expire
     *   The time to live for items, in seconds.
     */
    public function setMultipleWithExpire(array $data, $expire);

}

Interfaces

Title Deprecated Summary
KeyValueStoreExpirableInterface Defines the interface for expiring data in a key/value store.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.