Skip to main content

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

ParameterTypeDescription
keyStringKey name for the data you're storing
datadynamicValue to store. null deletes the key

Returns

void

Notes

  • Internally, the value goes into LucyStorage under 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 null or 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

ItemsetSharedDatasetStoreDatasetVar
Storage locationApp process memoryDisk (LucyStorage)App variable system (LucyVarMngr)
PersistenceLost when the app exitsKept across app restartsLost when the app exits
How it's definedAny key you choose in codeAny key you choose in codeMust be predefined in Studio
Read function$app.getSharedData(key)$app.getStoreData(key)$app.getVar(name)
How to deletePass a null valuePass a null valueValue changes only
Typical useSharing temporary data between pagesPermanent storage for user settings, login tokens, and the likeControlling app variables wired to the Studio UI
SpeedFast (memory)Relatively slow (disk I/O)Fast (memory)
  • $app.getStoreData(key)
  • $app.removeStoreData(key)
  • $app.setSharedData(sharedKey, data)