stella-cache

0.0.1 • Public • Published

stella-cache

a thin api allowing you to create multiple cache stores using redis.

Installation:

npm install stella-cache

Docs:

Contrived Example:

index.js:

// Initialize your app
var httpLoader = require('./httpLoader');
var dbLoader = require('./dbLoader');
var cacheLoader = require('./cacheLoader');

httpLoader.listen();

cacheLoader.js:

var cache = require('stella-cache'),
    httpCacheConfig = {},
    dbCacheConfig = {};

// stella-cache config options
httpCacheConfig = {
    name: 'httpCache',
    port: '6379',
    host: '10.10.10.1',
    options: {}
};

dbCacheConfig = {
    name: 'dbCache',
    port: '6379',
    host: '10.10.10.2',
    options: {return_buffers = true}
};

// create cache clients
cache.createCache(httpCacheConfig, function () {
    console.log(httpCacheConfig.name + ' created');
});

cache.createCache(dbCacheConfig, function () {
    console.log(dbCacheConfig.name + ' created');
});

someOtherFile.js

var db = require('someDB');
var dbCache = require('stella-cache').cacheStore.dbCache;

var user = db.get('12345', function (err, user) {
    
    var item: {
        expire: 30,
        key: user.userId
        value: {
            user: {
                userId: user.userId,
                username: user.username,
                note: 'Some notes.'
            }
        }
    }
            
    dbCache.put(item);
};

License

Copyright (c) 2013 Kevin J. Neff MIT License

Readme

Keywords

none

Package Sidebar

Install

npm i stella-cache

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • kjneff