5forcegees / node_microservices-cache

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Synopsis

This is a custom cache library that wraps the node_redis module (https://github.com/NodeRedis/node_redis) which exposes a 'client' object you can use to interact with the Redis server.

Our custom wrapper exposes 'client' through the getRedisClient() function.

Initialization

var cache = require('cache')();

Note: the () after the require statement is mandatory.

The cache object exposes a function called getRedisClient() that is used to initiate commands with the Redis server.

var cache = require('cache')(config);

Usage

Redis HSET example:

HSET hash field value
cache.getRedisClient().hset('hash', 'field', 'value', function(err, result) {
    // Callback for handling errors
});

Redis HGET example:

HGET hash field value
cache.getRedisClient().hget('hash', 'field', function(err, result) {
    // Callback for handling the result
});

About


Languages

Language:JavaScript 100.0%