setStoreData
Description
Saves a value permanently to app-scoped local storage (disk). Pass null as data to delete that key. Unlike setSharedData, the value survives an app restart.
Parameters
| Parameter | Type | Description |
|---|---|---|
| key | String | Key name for the data you're storing |
| data | dynamic | Value to store. null deletes the key |
Returns
void
Notes
- Internally, the value goes into
LucyStorageunder a key prefixed with the app scope. - Because it uses disk I/O, it's relatively slower than
setSharedData. - Use it for values that must outlive an app restart, such as login tokens and theme or user settings.
- To delete a single key, pass
nullor call$app.removeStoreData(key).
Example
// Permanently store the dark theme setting
$app.setStoreData("THEME_MODE", 1);
// Delete the stored value
$app.setStoreData("THEME_MODE", null);
setSharedData vs setStoreData vs setVar comparison
| Item | setSharedData | setStoreData | setVar |
|---|---|---|---|
| Storage location | App process memory | Disk (LucyStorage) | App variable system (LucyVarMngr) |
| Persistence | Lost when the app exits | Kept across app restarts | Lost when the app exits |
| How it's defined | Any key you choose in code | Any key you choose in code | Must be predefined in Studio |
| Read function | $app.getSharedData(key) | $app.getStoreData(key) | $app.getVar(name) |
| How to delete | Pass a null value | Pass a null value | Value changes only |
| Typical use | Sharing temporary data between pages | Permanent storage for user settings, login tokens, and the like | Controlling app variables wired to the Studio UI |
| Speed | Fast (memory) | Relatively slow (disk I/O) | Fast (memory) |
Related
$app.getStoreData(key)$app.removeStoreData(key)$app.setSharedData(sharedKey, data)