Hapi Cache Manager
Hapi Cache Manager plugin
Manage your Catbox cache through REST endpoints and server methods.
Plugin options
namespace
- (Default:cache
) Namespace for methods registered by the plugin.dependencies
- (Default:[]
) An array of plugin name strings that must be registered before cache managerinvalidate
- Cache invalidation options objectpath
- (Default:/cache/invalidate
) Server endpoint to expose through DELETE methodauth
- (Default:false
) Hapi auth strategy to use for cache invalidation endpoint
statistics
- Cache statistics options objectpath
- (Default:/cache/statistics
) Server endpoint to expose through GET methodauth
- (Default:false
) Hapi auth strategy to use for cache statistics endpoint
Installation
const Hapi = ;const CacheManager = ; const server = ;server; server; serverstart { if err throw err; console;};
Cache Statistics
You can get cache statistics for a single method or for all methods registered on the server:
# get statistics for all methods curl http://localhost:3000/cache/statistics# { # 'somemethod': { # sets: 0, gets: 2, hits: 1, stales: 0, generates: 1, errors: 0 # }, # 'someothermethod': { ... } } # get statistics for a single method curl http://localhost:3000/cache/statistics\?name\=somemethod# { # sets: 0, gets: 3, hits: 2, stales: 0, generates: 1, errors: 0 # }
Cache Invalidation
You can drop as many cached keys for as many methods as you want with either a single external request or internally by calling a server method.
const payload = data: name: 'methodname' keys: 'blabla' '123' name: 'someothermethodname' keys: 'abc' ... ; // through RESTserver; // through server methodservermethodscache;
MIT Public License.