cache

Contains caching functions.

Since: 3.0.0
Example

// Add an item to the cache
lando.cache.set('mykey', data);

// Get an item from the cache
var value = lando.cache.get('mykey');

// Remove an item from the cache
lando.cache.remove('mykey');

cache.set(key, data, [opts])

Sets an item in the cache

Kind: static method of cache
Since: 3.0.0

Param Type Default Description
key String The name of the key to store the data with.
data Any The data to store in the cache.
[opts] Object Options to pass into the cache
[opts.persist] Boolean false Whether this cache data should persist between processes. Eg in a file instead of memory
[opts.ttl] Integer 0 Seconds the cache should live. 0 mean forever.

Example

// Add a string to the cache
lando.cache.set('mykey', 'mystring');

// Add an object to persist in the file cache
lando.cache.set('mykey', data, {persist: true});

// Add an object to the cache for five seconds
lando.cache.set('mykey', data, {ttl: 5});

cache.get(key) ⇒ Any

Gets an item in the cache

Kind: static method of cache
Returns: Any - The data stored in the cache if applicable.
Since: 3.0.0

Param Type Description
key String The name of the key to retrieve the data.

Example

// Get the data stored with key mykey
var data = lando.cache.get('mykey');

cache.remove(key)

Manually remove an item from the cache.

Kind: static method of cache
Since: 3.0.0

Param Type Description
key String The name of the key to remove the data.

Example

// Remove the data stored with key mykey
lando.cache.remove('mykey');

results matching ""

    No results matching ""