DatabaseStorageExpirable
class DatabaseStorageExpirable extends DatabaseStorage implements KeyValueStoreExpirableInterface (View source)
Defines a default key/value store implementation for expiring items.
This key/value store implementation uses the database to store key/value data with an expire date.
Traits
Provides dependency injection friendly methods for serialization.
Properties
| protected string | $collection | The name of the collection holding key and value pairs. |
from StorageBase |
| protected array | $_serviceIds | An array of service IDs keyed by property name used for serialization. |
from DependencySerializationTrait |
| protected array | $_entityStorages | An array of entity type IDs keyed by the property name of their storages. |
from DependencySerializationTrait |
| protected SerializationInterface | $serializer | The serialization class to use. |
from DatabaseStorage |
| protected Connection | $connection | The database connection. |
from DatabaseStorage |
| protected string | $table | The name of the SQL table to use. |
from DatabaseStorage |
Methods
Overrides Drupal\Core\KeyValueStore\StorageBase::__construct().
Returns the stored value for a given key.
Returns whether a given key exists in the store.
Returns the stored key/value pairs for a given set of keys.
Returns all stored key/value pairs in the collection.
Saves a value for a given key if it does not exist yet.
Deletes multiple items from the key/value store.
Saves a value for a given key with a time to live.
Sets a value for a given key with a time to live if it does not yet exist.
Saves an array of values with a time to live.
Details
__construct($collection, SerializationInterface $serializer, Connection $connection, string $table = 'key_value_expire')
Overrides Drupal\Core\KeyValueStore\StorageBase::__construct().
string
getCollectionName()
Returns the name of this collection.
mixed
get(string $key, mixed $default = NULL)
Returns the stored value for a given key.
setMultiple(array $data)
Saves key/value pairs.
delete(string $key)
Deletes an item from the key/value store.
__sleep()
{@inheritdoc}
__wakeup()
{@inheritdoc}
bool
has(string $key)
Returns whether a given key exists in the store.
array
getMultiple(array $keys)
Returns the stored key/value pairs for a given set of keys.
array
getAll()
Returns all stored key/value pairs in the collection.
set(string $key, mixed $value)
Saves a value for a given key.
bool
setIfNotExists(string $key, mixed $value)
Saves a value for a given key if it does not exist yet.
rename(string $key, string $new_key)
Renames a key.
deleteMultiple(array $keys)
Deletes multiple items from the key/value store.
deleteAll()
Deletes all items from the key/value store.
setWithExpire(string $key, mixed $value, int $expire)
Saves a value for a given key with a time to live.
bool
setWithExpireIfNotExists(string $key, mixed $value, int $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.
setMultipleWithExpire(array $data, int $expire)
Saves an array of values with a time to live.