Products · Dash API

Cache

Keep values on the phone for a while, each with an optional expiry time.

A dot's own key-value cache, apart from its files. It holds up to 64 MB of JSON values, each kept until removed or until its ttl runs out.

dash.storage.cache.get

TypeScript
dash.storage.cache.get<Value extends CacheValue = CacheValue>(key: string, callOptions?: CallOptions): DashRequest<Value | null>

Resolves with null for a missing or expired key.

Types: CacheValue

dash.storage.cache.set

TypeScript
dash.storage.cache.set(key: string, value: CacheValue, options?: CacheSetOptions, callOptions?: CallOptions): DashRequest<void>

Saves value under key. Give { ttl } in milliseconds to have it expire, such as 60 000 for a minute; without it, the value stays until you remove it.

Types: CacheValue, CacheSetOptions

dash.storage.cache.remove

TypeScript
dash.storage.cache.remove(key: string, callOptions?: CallOptions): DashRequest<void>

Deletes the value saved under key.

dash.storage.cache.exists

TypeScript
dash.storage.cache.exists(key: string, callOptions?: CallOptions): DashRequest<boolean>

Whether a value is saved under key and hasn't expired.

dash.storage.cache.keys

TypeScript
dash.storage.cache.keys(callOptions?: CallOptions): DashRequest<string[]>

Every key with a value that hasn't expired, sorted.

dash.storage.cache.clear

TypeScript
dash.storage.cache.clear(callOptions?: CallOptions): DashRequest<void>

Deletes everything in the dot's cache.

Types

CacheValue

TypeScript
type CacheValue = string | number | boolean | CacheValue[] | { [key: string]: CacheValue };

CacheSetOptions

FieldTypeWhat it is
ttl (optional)numberHow many milliseconds the entry lasts. Without it, or with 0 or less, it lasts until removed.

Keep reading