Tags
Persistent Storage with {store}
By using the {store}
tag you can persist data across multiple scripts.
{store.set;key;value}
{store.get;key} // value
You can persist objects and arrays. There are limits on how many items can be stored and how much data can be stored per key.
{=user.id;1}
{=user.level;0}
{=user.balance;100}
{store.set;user;{$user}} // Store the {$user} variable at the "user" key
// Some time later...
{=user;{store.get;user}}
{$user.id} // 1
{$user.level} // 0
{$user.balance} // 100
The {store}
tags do not understand nested keys, so you can't retrieve partial information with them.
{=user.id;1}
{store.set;user;{$user}}
{store.get;user.id} // This will return nothing because it looks up the "user.id" key, not the "user" key.
// This works the other way around
{store.set;user.id;1}
{store.get;user} // Prints nothing because it looks up the "user" key while our data is stored at the "user.id" key.
{store.set;key;value}
Note
This tag is part of the Store
expensive group.
Adds an item to the store. value
can be an object, array, string, number, etc. key
will be coerced to a string.
Name | Type | Description |
---|---|---|
key | string | The key to store the value under. |
value | any | The value to store. |
{store.get;key}
Note
This tag is part of the Store
expensive group.
Gets an item from the store.
Name | Type | Description |
---|---|---|
key | string | The key to retrieve the value from. |
{store.delete;key}
Note
This tag is part of the Store
expensive group.
Deletes an item from the store.
Name | Type | Description |
---|---|---|
key | string | The key to delete. |