Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: node_js
node_js:
- 0.8
- '0.10'
- "0.12"
- "0.11"
- "0.10"
services:
- redis-server
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var stow = require('stow');

// Create your cache.
var cache = stow.createCache(stow.backends.Redis, {
nodes: ['localhost:6379']
redis: 'localhost:6379'
});

// Add items to the cache.
Expand Down
15 changes: 7 additions & 8 deletions backends/redis.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
var redis = require('haredis')
, hydration = require('hydration');
var redis = require('redis');

function RedisBackend (options) {
this.ttl = options.ttl;
this.prefix = options.prefix || 'stow:';
if (options.client) {
this.client = options.client;
}
else if (options.nodes) {
this.client = redis.createClient(options.nodes, options);
else if (options) {
this.client = redis.createClient(options.redis, options);
}
else {
this.client = redis.createClient(['localhost:6379'], options);
this.client = redis.createClient('localhost:6379', options);
}
if (options.db) {
this.client.select(db);
Expand All @@ -36,7 +35,7 @@ RedisBackend.prototype.set = function (options, cb) {
item.checksum = checksum;
var data;
try {
data = JSON.stringify(hydration.dehydrate(item));
data = JSON.stringify(item);
}
catch (e) {
return cb(e);
Expand All @@ -57,7 +56,7 @@ RedisBackend.prototype.get = function (key, cb) {
if (!result) return cb(null, null);
var item;
try {
item = hydration.hydrate(JSON.parse(result));
item = JSON.parse(result);
}
catch (e) {
return cb(e);
Expand Down Expand Up @@ -138,4 +137,4 @@ RedisBackend.prototype.validate = function (item, cb) {
}
};

module.exports = RedisBackend;
module.exports = RedisBackend;
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"name": "stow",
"version": "0.0.6",
"version": "0.0.8",
"description": "Caching with a flexible invalidation strategy",
"main": "stow.js",
"dependencies": {
"hydration": "~0.4.0",
"haredis": "~0.2.8"
"redis": "^2.2.5"
},
"devDependencies": {
"mocha": "*"
Expand Down
4 changes: 2 additions & 2 deletions test/common.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
stow = require('../');
assert = require('assert');
util = require('util');
redis = require('haredis');
redis = require('redis');

// Test a backend.
testBackend = function (Backend, options) {
Expand Down Expand Up @@ -262,4 +262,4 @@ testBackend = function (Backend, options) {
});
}

};
};