You are here

class DatabaseStorageExpirable in Service Container 7.2

Same name in this branch
  1. 7.2 src/KeyValueStore/DatabaseStorageExpirable.php \Drupal\service_container\KeyValueStore\DatabaseStorageExpirable
  2. 7.2 lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php \Drupal\Core\KeyValueStore\DatabaseStorageExpirable
Same name and namespace in other branches
  1. 7 src/KeyValueStore/DatabaseStorageExpirable.php \Drupal\service_container\KeyValueStore\DatabaseStorageExpirable

Overrides the KV store from Drupal to call MergeQuery::key instead of ::keys.

@codeCoverageIgnore

Hierarchy

Expanded class hierarchy of DatabaseStorageExpirable

File

src/KeyValueStore/DatabaseStorageExpirable.php, line 15
Contains \Drupal\service_container\KeyValueStore\DatabaseStorageExpirable.

Namespace

Drupal\service_container\KeyValueStore
View source
class DatabaseStorageExpirable extends \Drupal\Core\KeyValueStore\DatabaseStorageExpirable {

  /**
   * {@inheritdoc}
   */
  function setWithExpire($key, $value, $expire) {

    // We are already writing to the table, so perform garbage collection at
    // the end of this request.
    $this->needsGarbageCollection = TRUE;
    $this->connection
      ->merge($this->table)
      ->key(array(
      'name' => $key,
      'collection' => $this->collection,
    ))
      ->fields(array(
      'value' => $this->serializer
        ->encode($value),
      'expire' => REQUEST_TIME + $expire,
    ))
      ->execute();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DatabaseStorage::$connection protected property The database connection.
DatabaseStorage::$serializer protected property The serialization class to use.
DatabaseStorage::$table protected property The name of the SQL table to use.
DatabaseStorage::deleteAll public function Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::deleteAll(). Overrides KeyValueStoreInterface::deleteAll
DatabaseStorage::rename public function Renames a key. Overrides KeyValueStoreInterface::rename
DatabaseStorage::set public function Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::set(). Overrides KeyValueStoreInterface::set
DatabaseStorage::setIfNotExists public function Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::setIfNotExists(). Overrides KeyValueStoreInterface::setIfNotExists
DatabaseStorageExpirable::$needsGarbageCollection protected property Flag indicating whether garbage collection should be performed.
DatabaseStorageExpirable::deleteMultiple public function Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::deleteMultiple(). Overrides DatabaseStorage::deleteMultiple
DatabaseStorageExpirable::destruct public function Implements Drupal\Core\DestructableInterface::destruct(). Overrides DestructableInterface::destruct
DatabaseStorageExpirable::garbageCollection protected function Deletes expired items.
DatabaseStorageExpirable::getAll public function Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::getAll(). Overrides DatabaseStorage::getAll
DatabaseStorageExpirable::getMultiple public function Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::getMultiple(). Overrides DatabaseStorage::getMultiple
DatabaseStorageExpirable::has public function Returns whether a given key exists in the store. Overrides DatabaseStorage::has
DatabaseStorageExpirable::setMultipleWithExpire function Saves an array of values with a time to live. Overrides KeyValueStoreExpirableInterface::setMultipleWithExpire
DatabaseStorageExpirable::setWithExpire function Saves a value for a given key with a time to live. Overrides DatabaseStorageExpirable::setWithExpire
DatabaseStorageExpirable::setWithExpireIfNotExists function Implements Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface::setWithExpireIfNotExists(). Overrides KeyValueStoreExpirableInterface::setWithExpireIfNotExists
DatabaseStorageExpirable::__construct public function Overrides Drupal\Core\KeyValueStore\StorageBase::__construct(). Overrides DatabaseStorage::__construct
StorageBase::$collection protected property The name of the collection holding key and value pairs.
StorageBase::delete public function Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::delete(). Overrides KeyValueStoreInterface::delete 1
StorageBase::get public function Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::get(). Overrides KeyValueStoreInterface::get 1
StorageBase::getCollectionName public function Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::getCollectionName(). Overrides KeyValueStoreInterface::getCollectionName
StorageBase::setMultiple public function Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::setMultiple(). Overrides KeyValueStoreInterface::setMultiple 1