0.3.3 • Published 10 years ago
concordia-redis v0.3.3
Concordia-redis
A redis module for Concordia. Implemented as a simple wrapper around the excellent Node Redis.
Usage
As a redis wrapper
All Node Redis commands are supported. For instance, you can use:
concordia.set('foo', 'bar');
As concordia-cache
You can use concordia-redis as as implementation of the concordia-cache. If you want to do this, require the module like so:
concordia.loadModule$(require('concordia-redis').concordiaCache);
Concordia cache is an extremely basic caching mechanism. It has a set and a get command.
concordia.cache.set('foo', 'bar')
.then(function(cacheKey) {
return concordia.cache.get('foo');
})
.then(function(result) {
console.log(result); //-> foo
});
If you don't feel like making up your own key, you can use a shortcut that creates a random key for you.
concordia.cache.dump('bar')
.then(function(key) {
console.log(key); //-> <uuid>
});
The set command takes a timeout in seconds as an optional argument.
concordia.cache.set('foo', 'bar', 30);
concordia.cache('bar', 30);
Configuration
Use the configuration options under the redis
key.
var options = {
redis: {
port: 6379, //optional
host: '127.0.0.1', //optional
//...other options.
}
}
To see what other options you can pass, check the redis.createClient
documentation.