Initialize a new instance.
Preferably use the KeyValueStore.open constructor to create a new instance.
An instance of a storage client.
The unique identifier of the storage.
The name of the storage, if available.
Delete a value from the KVS.
Key of the record to delete.
Overrides RequestManager.drop
Drop the storage, removing it from the underlying storage client and clearing the cache.
Get a value from KVS that will be automatically saved on changes.
Key of the record, to store the value.
Value to be used if the record does not exist yet. Should be a dictionary.
Return the value of the key.
Overrides Storage.get_metadata
Get the storage metadata.
Get the public URL for the given key.
Key of the record for which URL is required.
The public URL for the given key.
Iterate over the existing keys in the KVS.
Key to start the iteration from.
Maximum number of keys to return. None means no limit.
List all the existing keys in the KVS.
It uses client's iterate_keys method to get the keys.
Key to start the iteration from.
Maximum number of keys to return.
A list of keys in the KVS.
Overrides Storage.open
Open a storage, either restore existing or create a new one.
The storage ID.
The storage name (global scope, persists across runs). Name can only contain letters "a" through "z", the digits "0" through "9", and the hyphen ("-") but only in the middle of the string (e.g. "my-value-1").
The storage alias (run scope, creates unnamed storage).
Configuration object used during the storage creation or restoration process.
Underlying storage client to use. If not provided, the default global storage client from the service locator will be used.
Force autosaved values to be saved without waiting for an event in Event Manager.
Overrides RequestManager.purge
Purge the storage, removing all items from the underlying storage client.
This method does not remove the storage itself, e.g. don't remove the metadata, but clears all items within it.
Check if a record with the given key exists in the key-value store.
Key of the record to check for existence.
True if a record with the given key exists, False otherwise.
Set a value in the KVS.
Key of the record to set.
Value to set.
The MIME content type string.
Overrides Storage.id
Get the storage ID.
Overrides Storage.name
Get the storage name.
Key-value store is a storage for reading and writing data records with unique key identifiers.
The key-value store class acts as a high-level interface for storing, retrieving, and managing data records identified by unique string keys. It abstracts away the underlying storage implementation details, allowing you to work with the same API regardless of whether data is stored in memory, on disk, or in the cloud.
Each data record is associated with a specific MIME content type, allowing storage of various data formats such as JSON, text, images, HTML snapshots or any binary data. This class is commonly used to store inputs, outputs, and other artifacts of crawler operations.
You can instantiate a key-value store using the open class method, which will create a store with the specified name or id. The underlying storage implementation is determined by the configured storage client.
Usage