expeditious-engine-redis
An in redis engine for expeditious. Cache entries are - you guessed it - stored in a redis instance.
Usage
You can use this module standalone or with expeditious which is the recommended approach since it simplifies interactions and allows you to easily switch cache engines.
const expeditious = ; // This will be passed to redis.createClient(options)// https://www.npmjs.com/package/redis#rediscreateclientconst redisOptions = host: 'redis-server.acme.com' port: 6379; const countries = ; countries;
API
Each API function takes a callback function as the last parameter and it receives up to two arguments as per node.js convention, error err and an optional result, res.
set(key, value, expire, callback)
Set a key (String) in the cache with a given (String) value. expire must be a Number greater than 0.
get(key, callback)
Get a specific item from the cache. Returns null if the entry is not found.
del(key, callback)
Delete a specific item from the cache. Callback receives only an error parameter.
keys(ns, callback)
List all keys that this engine instance contains for the given namespace. This can be expensive as per the reddit docs for KEYS.
ttl(key, callback)
Get the time left before key expires. Returns null as res if the entry is not found.
flush(ns, callback)
Flush all items from the engine instance in the given namespace.