PolyCache
Library for cache multi drivers.
Install
npm install polycache
Usage
PolyCache = require "polycache" # PolyCache uses memory driver by default # and if configuration exists, uses each driver cache = # use memory driver cacheset"largeCsv:2014-06-01:2014-06-14"bigValue # to memory then-> cacheget"largeCsv:2014-06-01:2014-06-14" # from memory then-> cahceclose
Driver Rules
Use memory for the keys frequently used and the values that size are small, use redis or memcached for the keys used for multi hosts and use file for large value size.
PolyCache = require "polycache" cache = file: dir: "/tmp" redis: host: "localhost" port: 6379 cacheaddRule PolyCacheFilekey: /largeCsv/cacheaddRule PolyCacheFileval: gt: 1024 * 1024cacheaddRule PolyCacheRediskey: "sharedSetting"# and if any rules do not match, use memory driver cacheset"largeCsv:2014-06-01:2014-06-14"bigValue # to file then-> cacheget"largeCsv:2014-06-01:2014-06-14" # from file then-> cahceclose
no cache mode
if you do not use cache in development, so you can give app via env NO_CACHE=true.
$ NO_CACHE=true node app.js // it includes poly cache
or give configure:
noCache: true
Author
Muddy Dixon muddydixon@gmail.com
License
Apache License Version 2.0