Cache
The Cache commands provide a persistent key-value store across package executions.
set_cache
Stores a cache entry identified by cache_id.
set_cache(cache_id, data);
Arguments :
- cache_id is a non-empty string that uniquely identifies the cache data.
- data can be any value that can be converted to JSON, except null, false, 0 and an empty string. These values throw an exception.
Example:
let cache_id = "unique_id";
let data = "Data into cache";
set_cache(cache_id, data);
get_cache
Retrieves a cache entry identified by cache_id.
Returns the cached data, or null if no entry exists.
let result = get_cache(cache_id);
Arguments :
- cache_id is a non-empty string that uniquely identifies the cache data.
Example:
let cache_id = "unique_id";
let result = get_cache(cache_id);
log("cache value :", result);
clear_cache
Removes a cache entry identified by cache_id.
clear_cache(cache_id);
Arguments :
- cache_id is a non-empty string that uniquely identifies the cache data.
Example:
let cache_id = "unique_id";
clear_cache(cache_id);
cleanup_cache
Removes all cache entries.
cleanup_cache();
Example:
cleanup_cache();