0.0.10 • Published 8 years ago

polycache v0.0.10

Weekly downloads
-
License
Apache License Ve...
Repository
-
Last release
8 years ago

PolyCache Build Status

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 = new PolyCache

# use memory driver
cache.set("largeCsv:2014-06-01:2014-06-14", bigValue) # to memory
.then(->
  cache.get("largeCsv:2014-06-01:2014-06-14") # from memory
)
.then(->
  cahce.close()
)

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 = new PolyCache
  file:
    dir: "/tmp"
  redis:
    host: "localhost"
    port: 6379

cache.addRule PolyCache.File, {key: /largeCsv/}
cache.addRule PolyCache.File, {val: {gt: 1024 * 1024}}
cache.addRule PolyCache.Redis, {key: "sharedSetting"}
# and if any rules do not match, use memory driver

cache.set("largeCsv:2014-06-01:2014-06-14", bigValue) # to file
.then(->
  cache.get("largeCsv:2014-06-01:2014-06-14") # from file
)
.then(->
  cahce.close()
)

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:

new PolyCache({noCache: true})

Author

Muddy Dixon muddydixon@gmail.com

License

Apache License Version 2.0

0.0.10

8 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago