An easy to use cache client that allows use for memcached, redis, or lru-cache
npm install cache-clientjavascript
config = {store: "redis", port:6379, host:"127.0.0.1", opts:{}, auth:"password"};
config = {store: "memory", opts:{}};
config = {store: "memcached", host:"localhost:11211", opts:{}};
var cacheClient = require("cache-client");
cacheClient.setup(config);
`
Usage
Normal Methods
`javascript
cacheClient.read("foo", function(result)
{
//do something here
});
cacheClient.write("foo", "bar");
`
Advanced Methods
You have access to the underlying modules(redis,memcached, lru) by calling cacheClient.client.method();
`javascript
cacheClient.client.keys();
cacheClient.client.values();
cacheClient.client.some_redis_method();
cacheClient.client.some_memcached_method();
`
API
* write(key,value,ttl) if ttl is not provided, then it will default to 0, which will cache the item until it is cleared.
* read(key, callback(result))
* remove(key)
* clear() -> must be careful with this, this will flush the entire cache, so if you are using the same store for both sessions and cache or multiple apps use the same store, this will clear everything.`