Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

catbox-redis

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

catbox-redis - npm Package Compare versions

Comparing version 1.1.1 to 2.0.0

28

examples/redis.js

@@ -0,1 +1,4 @@

'use strict';
// After starting this example load http://localhost:8080 and hit refresh, you will notice that it loads the response from cache for the first 5 seconds and then reloads the cache

@@ -5,4 +8,4 @@

var Catbox = require('catbox');
var Http = require('http');
const Catbox = require('catbox');
const Http = require('http');

@@ -13,3 +16,3 @@

var internals = {};
const internals = {};

@@ -19,3 +22,3 @@

internals.getResponse(function (err, item) {
internals.getResponse((err, item) => {

@@ -36,3 +39,3 @@ if (err) {

var key = {
const key = {
segment: 'example',

@@ -42,6 +45,6 @@ id: 'myExample'

var cacheValue = 'my example';
var ttl = 10000; // How long item will be cached in milliseconds
const cacheValue = 'my example';
const ttl = 10000; // How long item will be cached in milliseconds
internals.client.get(key, function (err, cached) {
internals.client.get(key, (err, cached) => {

@@ -54,3 +57,3 @@ if (err) {

}
internals.client.set(key, cacheValue, ttl, function (error) {
internals.client.set(key, cacheValue, ttl, (error) => {

@@ -65,3 +68,3 @@ callback(error, cacheValue);

var options = {
const options = {
partition: 'examples', // For redis this will store items under keys that start with examples:

@@ -84,4 +87,5 @@ host: '127.0.0.1', // If you don't supply, 127.0.0.1 is the default

process.exit();
} else {
var server = Http.createServer(internals.handler);
}
else {
const server = Http.createServer(internals.handler);
server.listen(8080);

@@ -88,0 +92,0 @@ console.log('Server started at http://localhost:8080/');

@@ -0,5 +1,8 @@

'use strict';
// Load modules
var Redis = require('redis');
var Hoek = require('hoek');
const Redis = require('redis');
const Hoek = require('hoek');

@@ -9,3 +12,3 @@

var internals = {};
const internals = {};

@@ -33,3 +36,3 @@

var self = this;
const self = this;
if (this.client) {

@@ -39,3 +42,3 @@ return Hoek.nextTick(callback)();

var client;
let client;

@@ -59,3 +62,3 @@ if (this.settings.socket) {

client.on('error', function (err) {
client.on('error', (err) => {

@@ -69,4 +72,5 @@ if (!self.client) { // Failed to connect

// Wait for connection
client.once('ready', function () {
client.once('ready', () => {
self.client = client;

@@ -114,3 +118,3 @@ return callback();

this.client.get(this.generateKey(key), function (err, result) {
this.client.get(this.generateKey(key), (err, result) => {

@@ -125,3 +129,3 @@ if (err) {

var envelope = null;
let envelope = null;
try {

@@ -149,3 +153,3 @@ envelope = JSON.parse(result);

var self = this;
const self = this;

@@ -156,3 +160,3 @@ if (!this.client) {

var envelope = {
const envelope = {
item: value,

@@ -163,5 +167,5 @@ stored: Date.now(),

var cacheKey = this.generateKey(key);
const cacheKey = this.generateKey(key);
var stringifiedEnvelope = null;
let stringifiedEnvelope = null;

@@ -175,3 +179,3 @@ try {

this.client.set(cacheKey, stringifiedEnvelope, function (err) {
this.client.set(cacheKey, stringifiedEnvelope, (err) => {

@@ -182,4 +186,4 @@ if (err) {

var ttlSec = Math.max(1, Math.floor(ttl / 1000));
self.client.expire(cacheKey, ttlSec, function (err) { // Use 'pexpire' with ttl in Redis 2.6.0
const ttlSec = Math.max(1, Math.floor(ttl / 1000));
self.client.expire(cacheKey, ttlSec, (err) => { // Use 'pexpire' with ttl in Redis 2.6.0

@@ -198,3 +202,3 @@ return callback(err);

this.client.del(this.generateKey(key), function (err) {
this.client.del(this.generateKey(key), (err) => {

@@ -208,3 +212,3 @@ return callback(err);

var parts = [];
const parts = [];

@@ -211,0 +215,0 @@ if (this.settings.partition) {

{
"name": "catbox-redis",
"description": "Redis adapter for catbox",
"version": "1.1.1",
"version": "2.0.0",
"author": "Eran Hammer <eran@hammer.io> (http://hueniverse.com)",

@@ -21,8 +21,8 @@ "contributors": [

"redis": "2.x.x",
"hoek": "2.x.x"
"hoek": "3.x.x"
},
"devDependencies": {
"catbox": "4.x.x",
"code": "1.x.x",
"lab": "6.x.x"
"catbox": "7.x.x",
"code": "2.x.x",
"lab": "10.x.x"
},

@@ -29,0 +29,0 @@ "scripts": {

@@ -0,8 +1,11 @@

'use strict';
// Load modules
var Code = require('code');
var Lab = require('lab');
var Catbox = require('catbox');
var Redis = require('..');
var RedisClient = require('redis');
const Code = require('code');
const Lab = require('lab');
const Catbox = require('catbox');
const Redis = require('..');
const RedisClient = require('redis');

@@ -12,3 +15,3 @@

var internals = {};
const internals = {};

@@ -18,13 +21,13 @@

var lab = exports.lab = Lab.script();
var expect = Code.expect;
var describe = lab.describe;
var it = lab.test;
const lab = exports.lab = Lab.script();
const expect = Code.expect;
const describe = lab.describe;
const it = lab.test;
describe('Redis', function () {
describe('Redis', () => {
it('throws an error if not created with new', function (done) {
it('throws an error if not created with new', (done) => {
var fn = function () {
const fn = () => {

@@ -38,17 +41,18 @@ Redis();

it('creates a new connection', function (done) {
it('creates a new connection', (done) => {
var client = new Catbox.Client(Redis);
client.start(function (err) {
const client = new Catbox.Client(Redis);
client.start((err) => {
expect(client.isReady()).to.equal(true);
done();
done(err);
});
});
it('closes the connection', function (done) {
it('closes the connection', (done) => {
var client = new Catbox.Client(Redis);
client.start(function (err) {
const client = new Catbox.Client(Redis);
client.start((err) => {
expect(err).to.not.exist();
expect(client.isReady()).to.equal(true);

@@ -61,8 +65,8 @@ client.stop();

it('allow passing client in option', function (done) {
it('allow passing client in option', (done) => {
var redisClient = RedisClient.createClient();
const redisClient = RedisClient.createClient();
var getCalled = false;
var _get = redisClient.get;
let getCalled = false;
const _get = redisClient.get;
redisClient.get = function (key, callback) {

@@ -75,13 +79,13 @@

redisClient.on('error', done);
redisClient.once('ready', function () {
redisClient.once('ready', () => {
var client = new Catbox.Client(Redis, {
const client = new Catbox.Client(Redis, {
client: redisClient
});
client.start(function (err) {
client.start((err) => {
expect(err).to.not.exist();
expect(client.isReady()).to.equal(true);
var key = { id: 'x', segment: 'test' };
client.get(key, function (err, result) {
const key = { id: 'x', segment: 'test' };
client.get(key, (err, result) => {

@@ -96,12 +100,13 @@ expect(err).to.equal(null);

it('gets an item after settig it', function (done) {
it('gets an item after settig it', (done) => {
var client = new Catbox.Client(Redis);
client.start(function (err) {
const client = new Catbox.Client(Redis);
client.start((err) => {
var key = { id: 'x', segment: 'test' };
client.set(key, '123', 500, function (err) {
expect(err).to.not.exist();
const key = { id: 'x', segment: 'test' };
client.set(key, '123', 500, (err) => {
expect(err).to.not.exist();
client.get(key, function (err, result) {
client.get(key, (err, result) => {

@@ -116,11 +121,12 @@ expect(err).to.equal(null);

it('fails setting an item circular references', function (done) {
it('fails setting an item circular references', (done) => {
var client = new Catbox.Client(Redis);
client.start(function (err) {
const client = new Catbox.Client(Redis);
client.start((err) => {
var key = { id: 'x', segment: 'test' };
var value = { a: 1 };
expect(err).to.not.exist();
const key = { id: 'x', segment: 'test' };
const value = { a: 1 };
value.b = value;
client.set(key, value, 10, function (err) {
client.set(key, value, 10, (err) => {

@@ -133,10 +139,11 @@ expect(err.message).to.equal('Converting circular structure to JSON');

it('ignored starting a connection twice on same event', function (done) {
it('ignored starting a connection twice on same event', (done) => {
var client = new Catbox.Client(Redis);
var x = 2;
var start = function () {
const client = new Catbox.Client(Redis);
let x = 2;
const start = () => {
client.start(function (err) {
client.start((err) => {
expect(err).to.not.exist();
expect(client.isReady()).to.equal(true);

@@ -154,6 +161,6 @@ --x;

it('ignored starting a connection twice chained', function (done) {
it('ignored starting a connection twice chained', (done) => {
var client = new Catbox.Client(Redis);
client.start(function (err) {
const client = new Catbox.Client(Redis);
client.start((err) => {

@@ -163,3 +170,3 @@ expect(err).to.not.exist();

client.start(function (err) {
client.start((err) => {

@@ -173,8 +180,9 @@ expect(err).to.not.exist();

it('returns not found on get when using null key', function (done) {
it('returns not found on get when using null key', (done) => {
var client = new Catbox.Client(Redis);
client.start(function (err) {
const client = new Catbox.Client(Redis);
client.start((err) => {
client.get(null, function (err, result) {
expect(err).to.not.exist();
client.get(null, (err, result) => {

@@ -188,14 +196,15 @@ expect(err).to.equal(null);

it('returns not found on get when item expired', function (done) {
it('returns not found on get when item expired', (done) => {
var client = new Catbox.Client(Redis);
client.start(function (err) {
const client = new Catbox.Client(Redis);
client.start((err) => {
var key = { id: 'x', segment: 'test' };
client.set(key, 'x', 1, function (err) {
expect(err).to.not.exist();
const key = { id: 'x', segment: 'test' };
client.set(key, 'x', 1, (err) => {
expect(err).to.not.exist();
setTimeout(function () {
setTimeout(() => {
client.get(key, function (err, result) {
client.get(key, (err, result) => {

@@ -211,8 +220,9 @@ expect(err).to.equal(null);

it('returns error on set when using null key', function (done) {
it('returns error on set when using null key', (done) => {
var client = new Catbox.Client(Redis);
client.start(function (err) {
const client = new Catbox.Client(Redis);
client.start((err) => {
client.set(null, {}, 1000, function (err) {
expect(err).to.not.exist();
client.set(null, {}, 1000, (err) => {

@@ -225,8 +235,9 @@ expect(err instanceof Error).to.equal(true);

it('returns error on get when using invalid key', function (done) {
it('returns error on get when using invalid key', (done) => {
var client = new Catbox.Client(Redis);
client.start(function (err) {
const client = new Catbox.Client(Redis);
client.start((err) => {
client.get({}, function (err) {
expect(err).to.not.exist();
client.get({}, (err) => {

@@ -239,8 +250,9 @@ expect(err instanceof Error).to.equal(true);

it('returns error on drop when using invalid key', function (done) {
it('returns error on drop when using invalid key', (done) => {
var client = new Catbox.Client(Redis);
client.start(function (err) {
const client = new Catbox.Client(Redis);
client.start((err) => {
client.drop({}, function (err) {
expect(err).to.not.exist();
client.drop({}, (err) => {

@@ -253,8 +265,9 @@ expect(err instanceof Error).to.equal(true);

it('returns error on set when using invalid key', function (done) {
it('returns error on set when using invalid key', (done) => {
var client = new Catbox.Client(Redis);
client.start(function (err) {
const client = new Catbox.Client(Redis);
client.start((err) => {
client.set({}, {}, 1000, function (err) {
expect(err).to.not.exist();
client.set({}, {}, 1000, (err) => {

@@ -267,9 +280,10 @@ expect(err instanceof Error).to.equal(true);

it('ignores set when using non-positive ttl value', function (done) {
it('ignores set when using non-positive ttl value', (done) => {
var client = new Catbox.Client(Redis);
client.start(function (err) {
const client = new Catbox.Client(Redis);
client.start((err) => {
var key = { id: 'x', segment: 'test' };
client.set(key, 'y', 0, function (err) {
expect(err).to.not.exist();
const key = { id: 'x', segment: 'test' };
client.set(key, 'y', 0, (err) => {

@@ -282,8 +296,9 @@ expect(err).to.not.exist();

it('returns error on drop when using null key', function (done) {
it('returns error on drop when using null key', (done) => {
var client = new Catbox.Client(Redis);
client.start(function (err) {
const client = new Catbox.Client(Redis);
client.start((err) => {
client.drop(null, function (err) {
expect(err).to.not.exist();
client.drop(null, (err) => {

@@ -296,8 +311,8 @@ expect(err instanceof Error).to.equal(true);

it('returns error on get when stopped', function (done) {
it('returns error on get when stopped', (done) => {
var client = new Catbox.Client(Redis);
const client = new Catbox.Client(Redis);
client.stop();
var key = { id: 'x', segment: 'test' };
client.connection.get(key, function (err, result) {
const key = { id: 'x', segment: 'test' };
client.connection.get(key, (err, result) => {

@@ -310,8 +325,8 @@ expect(err).to.exist();

it('returns error on set when stopped', function (done) {
it('returns error on set when stopped', (done) => {
var client = new Catbox.Client(Redis);
const client = new Catbox.Client(Redis);
client.stop();
var key = { id: 'x', segment: 'test' };
client.connection.set(key, 'y', 1, function (err) {
const key = { id: 'x', segment: 'test' };
client.connection.set(key, 'y', 1, (err) => {

@@ -323,8 +338,8 @@ expect(err).to.exist();

it('returns error on drop when stopped', function (done) {
it('returns error on drop when stopped', (done) => {
var client = new Catbox.Client(Redis);
const client = new Catbox.Client(Redis);
client.stop();
var key = { id: 'x', segment: 'test' };
client.connection.drop(key, function (err) {
const key = { id: 'x', segment: 'test' };
client.connection.drop(key, (err) => {

@@ -336,10 +351,10 @@ expect(err).to.exist();

it('returns error on missing segment name', function (done) {
it('returns error on missing segment name', (done) => {
var config = {
const config = {
expiresIn: 50000
};
var fn = function () {
const fn = () => {
var client = new Catbox.Client(Redis);
const client = new Catbox.Client(Redis);
new Catbox.Policy(config, client, '');

@@ -351,10 +366,10 @@ };

it('returns error on bad segment name', function (done) {
it('returns error on bad segment name', (done) => {
var config = {
const config = {
expiresIn: 50000
};
var fn = function () {
const fn = () => {
var client = new Catbox.Client(Redis);
const client = new Catbox.Client(Redis);
new Catbox.Policy(config, client, 'a\0b');

@@ -366,7 +381,7 @@ };

it('returns error when cache item dropped while stopped', function (done) {
it('returns error when cache item dropped while stopped', (done) => {
var client = new Catbox.Client(Redis);
const client = new Catbox.Client(Redis);
client.stop();
client.drop('a', function (err) {
client.drop('a', (err) => {

@@ -378,7 +393,7 @@ expect(err).to.exist();

describe('#start', function () {
describe('start()', () => {
it('sets client to when the connection succeeds', function (done) {
it('sets client to when the connection succeeds', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -388,5 +403,5 @@ port: 6379

var redis = new Redis(options);
const redis = new Redis(options);
redis.start(function (err) {
redis.start((err) => {

@@ -399,5 +414,5 @@ expect(err).to.not.exist();

it('reuses the client when a connection is already started', function (done) {
it('reuses the client when a connection is already started', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -407,10 +422,10 @@ port: 6379

var redis = new Redis(options);
const redis = new Redis(options);
redis.start(function (err) {
redis.start((err) => {
expect(err).to.not.exist();
var client = redis.client;
const client = redis.client;
redis.start(function () {
redis.start(() => {

@@ -423,5 +438,5 @@ expect(client).to.equal(redis.client);

it('returns an error when connection fails', function (done) {
it('returns an error when connection fails', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -431,5 +446,5 @@ port: 6380

var redis = new Redis(options);
const redis = new Redis(options);
redis.start(function (err) {
redis.start((err) => {

@@ -443,5 +458,5 @@ expect(err).to.exist();

it('sends auth command when password is provided', function (done) {
it('sends auth command when password is provided', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -452,5 +467,5 @@ port: 6379,

var redis = new Redis(options);
const redis = new Redis(options);
var log = console.log;
const log = console.log;
console.log = function (message) {

@@ -462,3 +477,3 @@

redis.start(function (err) {
redis.start((err) => {

@@ -470,5 +485,5 @@ expect(err).to.not.exist();

it('fails in error when auth is not correct', function (done) {
it('fails in error when auth is not correct', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -479,5 +494,5 @@ port: 6378,

var redis = new Redis(options);
const redis = new Redis(options);
redis.start(function (err) {
redis.start((err) => {

@@ -491,5 +506,5 @@ expect(err).to.exist();

it('success when auth is correct', function (done) {
it('success when auth is correct', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -500,3 +515,3 @@ port: 6378,

var redis = new Redis(options);
const redis = new Redis(options);

@@ -506,5 +521,5 @@ redis.start(done);

it('sends select command when database is provided', function (done) {
it('sends select command when database is provided', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -515,8 +530,8 @@ port: 6379,

var redis = new Redis(options);
const redis = new Redis(options);
redis.start(function () {});
redis.start(() => {});
// redis.client.selected_db gets updated after the callback
setTimeout(function () {
setTimeout(() => {

@@ -528,14 +543,14 @@ expect(redis.client.selected_db).to.equal(1);

it('connects to a unix domain socket when one is provided.', function (done) {
it('connects to a unix domain socket when one is provided.', (done) => {
var options = {
const options = {
socket: '/tmp/redis.sock'
};
var redis = new Redis(options);
const redis = new Redis(options);
redis.start(function (err) {
redis.start((err) => {
expect(err).to.not.exist();
var client = redis.client;
const client = redis.client;
expect(client).to.exist();

@@ -548,5 +563,5 @@ expect(client.connected).to.equal(true);

it('does not stops the client on error post connection', function (done) {
it('does not stops the client on error post connection', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -556,5 +571,5 @@ port: 6379

var redis = new Redis(options);
const redis = new Redis(options);
redis.start(function (err) {
redis.start((err) => {

@@ -571,7 +586,7 @@ expect(err).to.not.exist();

describe('#isReady', function () {
describe('isReady()', () => {
it('returns true when when connected', function (done) {
it('returns true when when connected', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -581,5 +596,5 @@ port: 6379

var redis = new Redis(options);
const redis = new Redis(options);
redis.start(function (err) {
redis.start((err) => {

@@ -595,5 +610,5 @@ expect(err).to.not.exist();

it('returns false when stopped', function (done) {
it('returns false when stopped', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -603,5 +618,5 @@ port: 6379

var redis = new Redis(options);
const redis = new Redis(options);
redis.start(function (err) {
redis.start((err) => {

@@ -619,5 +634,5 @@ expect(err).to.not.exist();

it('returns false when disconnected', function (done) {
it('returns false when disconnected', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -627,5 +642,5 @@ port: 6379

var redis = new Redis(options);
const redis = new Redis(options);
redis.start(function (err) {
redis.start((err) => {

@@ -645,7 +660,7 @@ expect(err).to.not.exist();

describe('#validateSegmentName', function () {
describe('validateSegmentName()', () => {
it('returns an error when the name is empty', function (done) {
it('returns an error when the name is empty', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -655,5 +670,5 @@ port: 6379

var redis = new Redis(options);
const redis = new Redis(options);
var result = redis.validateSegmentName('');
const result = redis.validateSegmentName('');

@@ -665,5 +680,5 @@ expect(result).to.be.instanceOf(Error);

it('returns an error when the name has a null character', function (done) {
it('returns an error when the name has a null character', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -673,5 +688,5 @@ port: 6379

var redis = new Redis(options);
const redis = new Redis(options);
var result = redis.validateSegmentName('\0test');
const result = redis.validateSegmentName('\0test');

@@ -682,5 +697,5 @@ expect(result).to.be.instanceOf(Error);

it('returns null when there aren\'t any errors', function (done) {
it('returns null when there aren\'t any errors', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -690,5 +705,5 @@ port: 6379

var redis = new Redis(options);
const redis = new Redis(options);
var result = redis.validateSegmentName('valid');
const result = redis.validateSegmentName('valid');

@@ -701,7 +716,7 @@ expect(result).to.not.be.instanceOf(Error);

describe('#get', function () {
describe('get()', () => {
it('passes an error to the callback when the connection is closed', function (done) {
it('passes an error to the callback when the connection is closed', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -711,5 +726,5 @@ port: 6379

var redis = new Redis(options);
const redis = new Redis(options);
redis.get('test', function (err) {
redis.get('test', (err) => {

@@ -723,5 +738,5 @@ expect(err).to.exist();

it('passes an error to the callback when there is an error returned from getting an item', function (done) {
it('passes an error to the callback when there is an error returned from getting an item', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -731,3 +746,3 @@ port: 6379

var redis = new Redis(options);
const redis = new Redis(options);
redis.client = {

@@ -740,3 +755,3 @@ get: function (item, callback) {

redis.get('test', function (err) {
redis.get('test', (err) => {

@@ -749,5 +764,5 @@ expect(err).to.exist();

it('passes an error to the callback when there is an error parsing the result', function (done) {
it('passes an error to the callback when there is an error parsing the result', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -757,3 +772,3 @@ port: 6379

var redis = new Redis(options);
const redis = new Redis(options);
redis.client = {

@@ -766,3 +781,3 @@ get: function (item, callback) {

redis.get('test', function (err) {
redis.get('test', (err) => {

@@ -775,5 +790,5 @@ expect(err).to.exist();

it('passes an error to the callback when there is an error with the envelope structure (stored)', function (done) {
it('passes an error to the callback when there is an error with the envelope structure (stored)', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -783,3 +798,3 @@ port: 6379

var redis = new Redis(options);
const redis = new Redis(options);
redis.client = {

@@ -792,3 +807,3 @@ get: function (item, callback) {

redis.get('test', function (err) {
redis.get('test', (err) => {

@@ -801,5 +816,5 @@ expect(err).to.exist();

it('passes an error to the callback when there is an error with the envelope structure (item)', function (done) {
it('passes an error to the callback when there is an error with the envelope structure (item)', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -809,3 +824,3 @@ port: 6379

var redis = new Redis(options);
const redis = new Redis(options);
redis.client = {

@@ -818,3 +833,3 @@ get: function (item, callback) {

redis.get('test', function (err) {
redis.get('test', (err) => {

@@ -827,5 +842,5 @@ expect(err).to.exist();

it('is able to retrieve an object thats stored when connection is started', function (done) {
it('is able to retrieve an object thats stored when connection is started', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -835,3 +850,3 @@ port: 6379,

};
var key = {
const key = {
id: 'test',

@@ -841,10 +856,10 @@ segment: 'test'

var redis = new Redis(options);
const redis = new Redis(options);
redis.start(function () {
redis.start(() => {
redis.set(key, 'myvalue', 200, function (err) {
redis.set(key, 'myvalue', 200, (err) => {
expect(err).to.not.exist();
redis.get(key, function (err, result) {
redis.get(key, (err, result) => {

@@ -859,5 +874,5 @@ expect(err).to.not.exist();

it('returns null when unable to find the item', function (done) {
it('returns null when unable to find the item', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -867,3 +882,3 @@ port: 6379,

};
var key = {
const key = {
id: 'notfound',

@@ -873,7 +888,7 @@ segment: 'notfound'

var redis = new Redis(options);
const redis = new Redis(options);
redis.start(function () {
redis.start(() => {
redis.get(key, function (err, result) {
redis.get(key, (err, result) => {

@@ -888,7 +903,7 @@ expect(err).to.not.exist();

describe('#set', function () {
describe('set()', () => {
it('passes an error to the callback when the connection is closed', function (done) {
it('passes an error to the callback when the connection is closed', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -898,5 +913,5 @@ port: 6379

var redis = new Redis(options);
const redis = new Redis(options);
redis.set('test1', 'test1', 3600, function (err) {
redis.set('test1', 'test1', 3600, (err) => {

@@ -910,5 +925,5 @@ expect(err).to.exist();

it('passes an error to the callback when there is an error returned from setting an item', function (done) {
it('passes an error to the callback when there is an error returned from setting an item', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -918,3 +933,3 @@ port: 6379

var redis = new Redis(options);
const redis = new Redis(options);
redis.client = {

@@ -927,3 +942,3 @@ set: function (key, item, callback) {

redis.set('test', 'test', 3600, function (err) {
redis.set('test', 'test', 3600, (err) => {

@@ -937,7 +952,7 @@ expect(err).to.exist();

describe('#drop', function () {
describe('drop()', () => {
it('passes an error to the callback when the connection is closed', function (done) {
it('passes an error to the callback when the connection is closed', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -947,5 +962,5 @@ port: 6379

var redis = new Redis(options);
const redis = new Redis(options);
redis.drop('test2', function (err) {
redis.drop('test2', (err) => {

@@ -959,5 +974,5 @@ expect(err).to.exist();

it('deletes the item from redis', function (done) {
it('deletes the item from redis', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -967,3 +982,3 @@ port: 6379

var redis = new Redis(options);
const redis = new Redis(options);
redis.client = {

@@ -976,3 +991,3 @@ del: function (key, callback) {

redis.drop('test', function (err) {
redis.drop('test', (err) => {

@@ -985,13 +1000,13 @@ expect(err).to.not.exist();

describe('generateKey()', function () {
describe('generateKey()', () => {
it('generates the storage key from a given catbox key', function (done) {
it('generates the storage key from a given catbox key', (done) => {
var options = {
const options = {
partition: 'foo'
};
var redis = new Redis(options);
const redis = new Redis(options);
var key = {
const key = {
id: 'bar',

@@ -1005,9 +1020,9 @@ segment: 'baz'

it('generates the storage key from a given catbox key without partition', function (done) {
it('generates the storage key from a given catbox key without partition', (done) => {
var options = {};
const options = {};
var redis = new Redis(options);
const redis = new Redis(options);
var key = {
const key = {
id: 'bar',

@@ -1022,7 +1037,7 @@ segment: 'baz'

describe('#stop', function () {
describe('stop()', () => {
it('sets the client to null', function (done) {
it('sets the client to null', (done) => {
var options = {
const options = {
host: '127.0.0.1',

@@ -1032,5 +1047,5 @@ port: 6379

var redis = new Redis(options);
const redis = new Redis(options);
redis.start(function () {
redis.start(() => {

@@ -1037,0 +1052,0 @@ expect(redis.client).to.exist();

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc