Persistent Storage

Saves small amounts of information on your device, so the Lens remembers it next time you open it. Use it for your settings, your progress or your own best score.

Utilities & Storage

Asset stores, saved data, and the core building blocks behind bigger experiences.

Made with this block

Inputs

storagePrefixstring

Prefix prepended to all storage keys to avoid collisions between blocks in the same lens. Leave empty for no prefix.

Events

onStorageFull

Fired when persistent storage capacity is exceeded. Storage is automatically cleared when this happens.

onValueChanged

Fired after any value is written to storage via a put function.

Functions

getBoolboolean

Get a boolean value from persistent storage. Returns false if key does not exist.

putBoolvoid

Store a boolean value persistently.

getIntint

Get an integer value from persistent storage. Returns 0 if key does not exist.

putIntvoid

Store an integer value persistently.

getFloatfloat

Get a float value from persistent storage. Returns 0.0 if key does not exist.

putFloatvoid

Store a float value persistently.

getStringstring

Get a string value from persistent storage. Returns empty string if key does not exist. Use with JSON.stringify/JSON.parse for small objects only.

putStringvoid

Store a string value persistently. Use JSON.stringify for small objects only; do not store large blobs, logs, images, or histories.

getColorObject

Get a vec4 color value from persistent storage. Returns vec4(0,0,0,0) if key does not exist.

putColorvoid

Store a vec4 color value persistently.

hasKeyboolean

Check if a key exists in persistent storage.

removeKeyvoid

Remove a specific key from persistent storage.

clearAllvoid

Remove all stored data within this block's prefix namespace. If no prefix is set, clears all persistent storage.

getAllKeysObject

Get an array of all keys currently stored within this block's prefix namespace (keys returned without the prefix).

getStorageInfostring

Get storage usage as a string in the format 'usedBytes/maxBytes'.