Script Development / Simple Storage DFF.STORE
DataFlux Func includes a built-in simple persistent storage feature DFF.STORE.
For scenarios requiring data storage with relatively simple needs, this built-in storage feature can be used directly.
The storage feature follows a Scope-Key-Value structure. The same Key is allowed to exist under different namespaces.
Simple Storage Preserves Original Data Types
When operating the simple storage, written data is automatically serialized; data is also automatically deserialized upon reading.
Therefore, manual serialization processing is not required during use.
DFF.STORE.set(...)
Store data. Parameters are as follows:
| Parameter | Type | Required / Default | Description |
|---|---|---|---|
key |
str | Required | Key name |
value |
Any JSON-serializable object | Required | Data |
expires / expire |
int | None |
Expiration time. Unit: seconds None means never expires |
not_exists |
bool | False |
Whether to write only when the data does not exist |
scope |
str | Current script name | Namespace |
| Example | |
|---|---|
1 | |
DFF.STORE.mset(...)
Added in version 6.0.6
Batch store data. Parameters are as follows:
| Parameter | Type | Required / Default | Description |
|---|---|---|---|
key_values |
dict | Required | Key-data dictionary |
expires / expire |
int | None |
Expiration time. Unit: seconds None means never expires |
not_exists |
bool | False |
Whether to write only when the data does not exist |
scope |
str | Current script name | Namespace |
| Example | |
|---|---|
1 2 3 4 5 | |
DFF.STORE.keys(...)
Get a list of Keys. Parameters are as follows:
| Parameter | Type | Required / Default | Description |
|---|---|---|---|
pattern |
str | "*" |
Key name matching pattern Supports * wildcard |
scope |
str | Current script name | Namespace |
| Example | |
|---|---|
1 2 3 4 | |
DFF.STORE.get(...)
Get stored data. Parameters are as follows:
| Parameter | Type | Required / Default | Description |
|---|---|---|---|
key |
str | Required | Key name |
scope |
str | Current script name | Namespace |
| Example | |
|---|---|
1 2 3 | |
DFF.STORE.mget(...)
Added in version 6.0.6
Batch get stored data. Parameters are as follows:
| Parameter | Type | Required / Default | Description |
|---|---|---|---|
keys |
list | Required | List of key names |
scope |
str | Current script name | Namespace |
| Example | |
|---|---|
1 2 3 4 5 | |
DFF.STORE.getall(...)
Added in version 6.0.6
Get all stored data. Parameters are as follows:
| Parameter | Type | Required / Default | Description |
|---|---|---|---|
scope |
str | Current script name | Namespace |
| Example | |
|---|---|
1 2 3 4 5 | |
DFF.STORE.get_pattern(...)
Added in version 6.0.6
Get stored data based on a key name matching pattern. Parameters are as follows:
| Parameter | Type | Required / Default | Description |
|---|---|---|---|
pattern |
str | "*" |
Key name matching pattern Supports * wildcard |
scope |
str | Current script name | Namespace |
| Example | |
|---|---|
1 2 3 4 5 | |
DFF.STORE.delete(...)
Delete stored data. Parameters are as follows:
| Parameter | Type | Required / Default | Description |
|---|---|---|---|
key |
str | Required | Key name |
scope |
str | Current script name | Namespace |
| Example | |
|---|---|
1 | |
DFF.STORE.delete_pattern(...)
Added in version 6.0.6
Delete stored data based on a key name matching pattern. Parameters are as follows:
| Parameter | Type | Required / Default | Description |
|---|---|---|---|
pattern |
str | "*" |
Key name matching pattern Supports * wildcard |
scope |
str | Current script name | Namespace |
| Example | |
|---|---|
1 2 3 4 | |