Storage
The Storage module provides a lightweight persistent key-value storage system for scripts. It allows scripts to save and retrieve simple typed data as well as binary data (Data). All data is persisted asynchronously in the background.
By default, all values are stored in the private domain of the current script, which means other scripts cannot access them. To share data across multiple scripts, set the shared: true option to use the shared domain instead.
Supported Data Types
The following types can be stored using the Storage API:
stringnumberbooleanJSON(any JSON-serializable structure)Data(usingsetData/getData)
Storage Domains
API Reference
1. Storage.set(key, value, options?)
Stores a value in persistent storage. Supports string, number, boolean, and JSON-serializable values.
Parameters
Returns
boolean— whether the operation was successful.
2. Storage.get(key, options?)
Retrieves a stored value. Returns null if the key does not exist.
Returns
T | null— the value associated with the key ornull.
3. Storage.setData(key, data, options?)
Stores a Data object in persistent storage.
4. Storage.getData(key, options?)
Retrieves a stored Data object. Returns null if the key does not exist.
5. Storage.remove(key, options?)
Removes the entry associated with the specified key.
6. Storage.contains(key, options?)
Checks whether the storage contains the specified key.
7. Storage.clear()
Removes all entries from the private storage domain. This does not affect shared storage.
8. Storage.keys()
Returns an array of all keys stored in the current storage domain.
Usage Examples
Example 1: Store and retrieve simple values
Example 2: Store a JSON object
Example 3: Store and read binary Data
Example 4: Shared domain usage
Example 5: Check existence and remove
Example 6: List all keys
Notes and Best Practices
- All writes are persisted asynchronously, but the method returns immediately with a success flag.
Datacannot be stored usingStorage.set(). UsesetData()/getData()instead.- JSON values must be fully serializable.
- Storage is intended for small, simple data. Avoid storing large binary blobs.
Storage.clear()only clears the private domain.
