1.1. Cache API¶
The cache API provides a temporary key-value based storage.
Functions
-
function
getCache
(string key)¶ Get a temporary cached value identified by its key.
- Return
- item value on success, nil otherwise.
- Note
- an empty string is returned if the key is not found.
- Parameters
key
: the item identifier.
-
function
setCache
(string key, string value, int expire_secs = nil)¶ Set a temporary cached value identified by a key.
- Note
- by convention, cache keys should start with “ntopng.cache.” .
- Parameters
key
: the item identifier.value
: the item value.expire_secs
: if set, the cache will expire after the specified seconds.
-
function
delCache
(string key)¶ Delete a previously cached value.
- Parameters
key
: the item identifier.
-
function
incrCache
(string key, int amount = 1)¶ Atomically increase a cached counter and get its new value.
- Return
- the new counter value
- Note
- the counter starts from 0 for newly created keys.
- Parameters
key
: the item identifier.amount
: the counter increment.