abstract class StorageBase implements KeyValueStoreInterface (View source)

Provides a base class for key/value storage implementations.

Properties

protected string $collection

The name of the collection holding key and value pairs.

Methods

__construct($collection)

{@inheritdoc}

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.

Details

__construct($collection)

{@inheritdoc}

Parameters

$collection

string getCollectionName()

Returns the name of this collection.

Return Value

string

The name of this collection.

mixed get(string $key, mixed $default = NULL)

Returns the stored value for a given key.

Parameters

string $key

The key of the data to retrieve.

mixed $default

The default value to use if the key is not found.

Return Value

mixed

The stored value, or the default value if no value exists.

setMultiple(array $data)

Saves key/value pairs.

Parameters

array $data

An associative array of key/value pairs.

delete(string $key)

Deletes an item from the key/value store.

Parameters

string $key

The item name to delete.