0.2.4 • Published 3 years ago

virgilio-redis-bannerwise v0.2.4

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Virgilio-redis

How to publish to npm

https://www.section.io/engineering-education/npm-packages/

wercker status Test Coverage NPM version

A redis module for Virgilio. 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:

virgilio.redis.set('foo', 'bar');

As virgilio-cache

You can use virgilio-redis as as implementation of the virgilio-cache. If you want to do this, require the module like so:

virgilio.loadModule$(require('virgilio-redis').virgilioCache);

Virgilio cache is an extremely basic caching mechanism. It has a set, get and a del command.

virgilio.cache.set('foo', 'bar')
    .then(function(cacheKey) {
        return virgilio.cache.get('foo');
    })
    .tap(console.log)       //-> 'foo'
    .then(function() {
        return virglio.cache.del('foo');
    })
    .tap(console.log);      //-> 'undefined'

If you don't feel like making up your own key, you can use a shortcut that creates a random key for you.

virgilio.cache.dump('bar')
    .then(function(key) {
        console.log(key); //-> <uuid>
    });

The set command takes a timeout in seconds as an optional argument.

virgilio.cache.set('foo', 'bar', 30);
virgilio.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.

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago