function DatabaseStorageExpirable::getMultiple

Same name in other branches
  1. 9 core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php \Drupal\Core\KeyValueStore\DatabaseStorageExpirable::getMultiple()
  2. 8.9.x core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php \Drupal\Core\KeyValueStore\DatabaseStorageExpirable::getMultiple()
  3. 11.x core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php \Drupal\Core\KeyValueStore\DatabaseStorageExpirable::getMultiple()

Overrides DatabaseStorage::getMultiple

File

core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php, line 70

Class

DatabaseStorageExpirable
Defines a default key/value store implementation for expiring items.

Namespace

Drupal\Core\KeyValueStore

Code

public function getMultiple(array $keys) {
    try {
        $values = $this->connection
            ->query('SELECT [name], [value] FROM {' . $this->connection
            ->escapeTable($this->table) . '} WHERE [expire] > :now AND [name] IN ( :keys[] ) AND [collection] = :collection', [
            ':now' => $this->time
                ->getRequestTime(),
            ':keys[]' => $keys,
            ':collection' => $this->collection,
        ])
            ->fetchAllKeyed();
        return array_map([
            $this->serializer,
            'decode',
        ], $values);
    } catch (\Exception $e) {
        // @todo Perhaps if the database is never going to be available,
        // key/value requests should return FALSE in order to allow exception
        // handling to occur but for now, keep it an array, always.
        // https://www.drupal.org/node/2787737
        $this->catchException($e);
    }
    return [];
}

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