Script Development / Simple Storage DFF.STORE
DFF.STORE is used to persist small-scale KV data, structured as scope + key -> value. Writes are automatically JSON-serialized; reads are automatically deserialized and preserve JSON types.
Complex queries or large amounts of data should use a database Connector. Short-lived, high-frequency data that can accept stringification should use DFF.CACHE.
Common Parameters
| Parameter | Required / Default | Description |
|---|---|---|
key |
Required | Key name, up to 256 characters |
value |
Required | JSON-serializable object |
expires |
None |
Expiration seconds; None means never expires |
scope |
Current Script ID | Namespace, up to 256 characters |
pattern |
"*" |
Key name pattern; * matches any length, ? matches a single character |
API
| Method | Return value / Description |
|---|---|
set(key, value, expires=None, not_exists=False, scope=None) |
Writes a single value; returns None |
mset(key_values, expires=None, not_exists=False, scope=None) |
Writes multiple values; returns None |
get(key, scope=None) / DFF.STORE(key, scope=None) |
Returns the value; returns None if it does not exist or has expired |
mget(keys, scope=None) |
Returns {key: value} |
getall(scope=None) |
Returns all data under the Scope |
keys(pattern='*', scope=None) |
Returns a list of matching Keys |
get_pattern(pattern='*', scope=None) |
Returns matching data {key: value} |
delete(key, scope=None) |
Deletes the specified Key |
delete_pattern(pattern='*', scope=None) |
Deletes matching Keys |
ref(key, scope=None, default=None) |
Creates a dynamic reference for DFF.API parameters that support dynamic values |
| Example | |
|---|---|
1 2 3 4 5 6 7 8 9 | |
mget(...) includes each requested Key; missing or expired values are None; get_pattern(...) only includes records that match and are still valid.
When using not_exists=True, a just-expired Key may still prevent creation. Both set(...) and mset(...) return None; to confirm creation results, read after writing. Batch writes are performed item by item and are not an all-or-nothing transaction.
A missing or falsy expires means no expiration; subsequent writes without an expiration time clear the previous expiration time. Old code may use the expire parameter; new code should use expires consistently.
Dynamic References
DFF.STORE.ref(...) returns a dynamic reference that can be used for the delayed_cron_job, timeout, expires, and queue parameters of DFF.API. When scope is omitted, the reference uses a dedicated REF Scope instead of the current Script Scope; you should usually explicitly pass a Scope consistent with the writer.
Pattern deletion matches the entire Scope by default
The default pattern of delete_pattern() is '*'. Unless you specifically need to delete the entire Scope, you must explicitly pass pattern and first use keys(...) to inspect the matching Keys.
Do not use DFF.STORE for long-term storage of large files or large lists.