Examples
banshee/examples-collection/examples/mechanics/
cache
Example: the cache, set, has, get and delete; a restart told by the boot id of the kernel.
by banshee1 installation1 version
Published on October 27, 2026. First version in this collection.
The cache
The cache keeps a few values from one pass to the next, each for a lifetime. Here, the boot id of the kernel: a different one from the previous pass means the host restarted.
How to read it
cache.set('boot-id', $boot_id, 86400): a key, a value, a lifetime in seconds, from 1 second to 7 days. A value not set again before the end of its lifetime is gone.cache.has('boot-id'): is the key there.cache.get('boot-id'): its value; a key missing or expired stops the collector, hencehasfirst.&&reads its right side only when the left one is true.cache.delete('boot-id'): forget the key.- A key is 1 to 64 characters of
a-z,0-9,.,_,-; 32 keys at most per probe. - The cache lives on the poller, per probe, and survives a restart of the poller. It is wiped when the probe changes collector or version.
To adapt it
- A token kept between passes is the most common use (see
examples/api/backup-jobs); a secret put in the cache is kept encrypted.