catbox-redis
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -1,4 +0,1 @@ | ||
'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 | ||
@@ -8,4 +5,4 @@ | ||
const Catbox = require('catbox'); | ||
const Http = require('http'); | ||
var Catbox = require('catbox'); | ||
var Http = require('http'); | ||
@@ -16,3 +13,3 @@ | ||
const internals = {}; | ||
var internals = {}; | ||
@@ -22,3 +19,3 @@ | ||
internals.getResponse((err, item) => { | ||
internals.getResponse(function (err, item) { | ||
@@ -39,3 +36,3 @@ if (err) { | ||
const key = { | ||
var key = { | ||
segment: 'example', | ||
@@ -45,6 +42,6 @@ id: 'myExample' | ||
const cacheValue = 'my example'; | ||
const ttl = 10000; // How long item will be cached in milliseconds | ||
var cacheValue = 'my example'; | ||
var ttl = 10000; // How long item will be cached in milliseconds | ||
internals.client.get(key, (err, cached) => { | ||
internals.client.get(key, function (err, cached) { | ||
@@ -57,3 +54,3 @@ if (err) { | ||
} | ||
internals.client.set(key, cacheValue, ttl, (error) => { | ||
internals.client.set(key, cacheValue, ttl, function (error) { | ||
@@ -68,3 +65,3 @@ callback(error, cacheValue); | ||
const options = { | ||
var options = { | ||
partition: 'examples', // For redis this will store items under keys that start with examples: | ||
@@ -87,5 +84,4 @@ host: '127.0.0.1', // If you don't supply, 127.0.0.1 is the default | ||
process.exit(); | ||
} | ||
else { | ||
const server = Http.createServer(internals.handler); | ||
} else { | ||
var server = Http.createServer(internals.handler); | ||
server.listen(8080); | ||
@@ -92,0 +88,0 @@ console.log('Server started at http://localhost:8080/'); |
@@ -1,8 +0,5 @@ | ||
'use strict'; | ||
// Load modules | ||
const Redis = require('redis'); | ||
const Hoek = require('hoek'); | ||
var Redis = require('redis'); | ||
var Hoek = require('hoek'); | ||
@@ -12,3 +9,3 @@ | ||
const internals = {}; | ||
var internals = {}; | ||
@@ -36,3 +33,3 @@ | ||
const self = this; | ||
var self = this; | ||
if (this.client) { | ||
@@ -42,3 +39,3 @@ return Hoek.nextTick(callback)(); | ||
let client; | ||
var client; | ||
@@ -62,3 +59,3 @@ if (this.settings.socket) { | ||
client.on('error', (err) => { | ||
client.on('error', function (err) { | ||
@@ -72,5 +69,4 @@ if (!self.client) { // Failed to connect | ||
// Wait for connection | ||
client.once('ready', function () { | ||
client.once('ready', () => { | ||
self.client = client; | ||
@@ -118,3 +114,3 @@ return callback(); | ||
this.client.get(this.generateKey(key), (err, result) => { | ||
this.client.get(this.generateKey(key), function (err, result) { | ||
@@ -129,3 +125,3 @@ if (err) { | ||
let envelope = null; | ||
var envelope = null; | ||
try { | ||
@@ -153,3 +149,3 @@ envelope = JSON.parse(result); | ||
const self = this; | ||
var self = this; | ||
@@ -160,3 +156,3 @@ if (!this.client) { | ||
const envelope = { | ||
var envelope = { | ||
item: value, | ||
@@ -167,5 +163,5 @@ stored: Date.now(), | ||
const cacheKey = this.generateKey(key); | ||
var cacheKey = this.generateKey(key); | ||
let stringifiedEnvelope = null; | ||
var stringifiedEnvelope = null; | ||
@@ -179,3 +175,3 @@ try { | ||
this.client.set(cacheKey, stringifiedEnvelope, (err) => { | ||
this.client.set(cacheKey, stringifiedEnvelope, function (err) { | ||
@@ -186,4 +182,4 @@ if (err) { | ||
const ttlSec = Math.max(1, Math.floor(ttl / 1000)); | ||
self.client.expire(cacheKey, ttlSec, (err) => { // Use 'pexpire' with ttl in Redis 2.6.0 | ||
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 | ||
@@ -202,3 +198,3 @@ return callback(err); | ||
this.client.del(this.generateKey(key), (err) => { | ||
this.client.del(this.generateKey(key), function (err) { | ||
@@ -212,3 +208,3 @@ return callback(err); | ||
const parts = []; | ||
var parts = []; | ||
@@ -215,0 +211,0 @@ if (this.settings.partition) { |
{ | ||
"name": "catbox-redis", | ||
"description": "Redis adapter for catbox", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"author": "Eran Hammer <eran@hammer.io> (http://hueniverse.com)", | ||
@@ -21,8 +21,8 @@ "contributors": [ | ||
"redis": "2.x.x", | ||
"hoek": "3.x.x" | ||
"hoek": "2.x.x" | ||
}, | ||
"devDependencies": { | ||
"catbox": "7.x.x", | ||
"code": "2.x.x", | ||
"lab": "10.x.x" | ||
"catbox": "4.x.x", | ||
"code": "1.x.x", | ||
"lab": "6.x.x" | ||
}, | ||
@@ -29,0 +29,0 @@ "scripts": { |
@@ -24,2 +24,4 @@ catbox-redis [![Build Status](https://travis-ci.org/hapijs/catbox-redis.svg?branch=master)](https://travis-ci.org/hapijs/catbox-redis) | ||
See [.travis.yml](./.travis.yml) | ||
```sh | ||
@@ -26,0 +28,0 @@ redis-server& |
@@ -1,11 +0,8 @@ | ||
'use strict'; | ||
// Load modules | ||
const Code = require('code'); | ||
const Lab = require('lab'); | ||
const Catbox = require('catbox'); | ||
const Redis = require('..'); | ||
const RedisClient = require('redis'); | ||
var Code = require('code'); | ||
var Lab = require('lab'); | ||
var Catbox = require('catbox'); | ||
var Redis = require('..'); | ||
var RedisClient = require('redis'); | ||
@@ -15,3 +12,3 @@ | ||
const internals = {}; | ||
var internals = {}; | ||
@@ -21,13 +18,13 @@ | ||
const lab = exports.lab = Lab.script(); | ||
const expect = Code.expect; | ||
const describe = lab.describe; | ||
const it = lab.test; | ||
var lab = exports.lab = Lab.script(); | ||
var expect = Code.expect; | ||
var describe = lab.describe; | ||
var it = lab.test; | ||
describe('Redis', () => { | ||
describe('Redis', function () { | ||
it('throws an error if not created with new', (done) => { | ||
it('throws an error if not created with new', function (done) { | ||
const fn = () => { | ||
var fn = function () { | ||
@@ -41,18 +38,17 @@ Redis(); | ||
it('creates a new connection', (done) => { | ||
it('creates a new connection', function (done) { | ||
const client = new Catbox.Client(Redis); | ||
client.start((err) => { | ||
var client = new Catbox.Client(Redis); | ||
client.start(function (err) { | ||
expect(client.isReady()).to.equal(true); | ||
done(err); | ||
done(); | ||
}); | ||
}); | ||
it('closes the connection', (done) => { | ||
it('closes the connection', function (done) { | ||
const client = new Catbox.Client(Redis); | ||
client.start((err) => { | ||
var client = new Catbox.Client(Redis); | ||
client.start(function (err) { | ||
expect(err).to.not.exist(); | ||
expect(client.isReady()).to.equal(true); | ||
@@ -65,8 +61,8 @@ client.stop(); | ||
it('allow passing client in option', (done) => { | ||
it('allow passing client in option', function (done) { | ||
const redisClient = RedisClient.createClient(); | ||
var redisClient = RedisClient.createClient(); | ||
let getCalled = false; | ||
const _get = redisClient.get; | ||
var getCalled = false; | ||
var _get = redisClient.get; | ||
redisClient.get = function (key, callback) { | ||
@@ -79,13 +75,13 @@ | ||
redisClient.on('error', done); | ||
redisClient.once('ready', () => { | ||
redisClient.once('ready', function () { | ||
const client = new Catbox.Client(Redis, { | ||
var client = new Catbox.Client(Redis, { | ||
client: redisClient | ||
}); | ||
client.start((err) => { | ||
client.start(function (err) { | ||
expect(err).to.not.exist(); | ||
expect(client.isReady()).to.equal(true); | ||
const key = { id: 'x', segment: 'test' }; | ||
client.get(key, (err, result) => { | ||
var key = { id: 'x', segment: 'test' }; | ||
client.get(key, function (err, result) { | ||
@@ -100,13 +96,12 @@ expect(err).to.equal(null); | ||
it('gets an item after settig it', (done) => { | ||
it('gets an item after settig it', function (done) { | ||
const client = new Catbox.Client(Redis); | ||
client.start((err) => { | ||
var client = new Catbox.Client(Redis); | ||
client.start(function (err) { | ||
expect(err).to.not.exist(); | ||
const key = { id: 'x', segment: 'test' }; | ||
client.set(key, '123', 500, (err) => { | ||
var key = { id: 'x', segment: 'test' }; | ||
client.set(key, '123', 500, function (err) { | ||
expect(err).to.not.exist(); | ||
client.get(key, (err, result) => { | ||
client.get(key, function (err, result) { | ||
@@ -121,12 +116,11 @@ expect(err).to.equal(null); | ||
it('fails setting an item circular references', (done) => { | ||
it('fails setting an item circular references', function (done) { | ||
const client = new Catbox.Client(Redis); | ||
client.start((err) => { | ||
var client = new Catbox.Client(Redis); | ||
client.start(function (err) { | ||
expect(err).to.not.exist(); | ||
const key = { id: 'x', segment: 'test' }; | ||
const value = { a: 1 }; | ||
var key = { id: 'x', segment: 'test' }; | ||
var value = { a: 1 }; | ||
value.b = value; | ||
client.set(key, value, 10, (err) => { | ||
client.set(key, value, 10, function (err) { | ||
@@ -139,11 +133,10 @@ expect(err.message).to.equal('Converting circular structure to JSON'); | ||
it('ignored starting a connection twice on same event', (done) => { | ||
it('ignored starting a connection twice on same event', function (done) { | ||
const client = new Catbox.Client(Redis); | ||
let x = 2; | ||
const start = () => { | ||
var client = new Catbox.Client(Redis); | ||
var x = 2; | ||
var start = function () { | ||
client.start((err) => { | ||
client.start(function (err) { | ||
expect(err).to.not.exist(); | ||
expect(client.isReady()).to.equal(true); | ||
@@ -161,6 +154,6 @@ --x; | ||
it('ignored starting a connection twice chained', (done) => { | ||
it('ignored starting a connection twice chained', function (done) { | ||
const client = new Catbox.Client(Redis); | ||
client.start((err) => { | ||
var client = new Catbox.Client(Redis); | ||
client.start(function (err) { | ||
@@ -170,3 +163,3 @@ expect(err).to.not.exist(); | ||
client.start((err) => { | ||
client.start(function (err) { | ||
@@ -180,9 +173,8 @@ expect(err).to.not.exist(); | ||
it('returns not found on get when using null key', (done) => { | ||
it('returns not found on get when using null key', function (done) { | ||
const client = new Catbox.Client(Redis); | ||
client.start((err) => { | ||
var client = new Catbox.Client(Redis); | ||
client.start(function (err) { | ||
expect(err).to.not.exist(); | ||
client.get(null, (err, result) => { | ||
client.get(null, function (err, result) { | ||
@@ -196,15 +188,14 @@ expect(err).to.equal(null); | ||
it('returns not found on get when item expired', (done) => { | ||
it('returns not found on get when item expired', function (done) { | ||
const client = new Catbox.Client(Redis); | ||
client.start((err) => { | ||
var client = new Catbox.Client(Redis); | ||
client.start(function (err) { | ||
expect(err).to.not.exist(); | ||
const key = { id: 'x', segment: 'test' }; | ||
client.set(key, 'x', 1, (err) => { | ||
var key = { id: 'x', segment: 'test' }; | ||
client.set(key, 'x', 1, function (err) { | ||
expect(err).to.not.exist(); | ||
setTimeout(() => { | ||
setTimeout(function () { | ||
client.get(key, (err, result) => { | ||
client.get(key, function (err, result) { | ||
@@ -220,9 +211,8 @@ expect(err).to.equal(null); | ||
it('returns error on set when using null key', (done) => { | ||
it('returns error on set when using null key', function (done) { | ||
const client = new Catbox.Client(Redis); | ||
client.start((err) => { | ||
var client = new Catbox.Client(Redis); | ||
client.start(function (err) { | ||
expect(err).to.not.exist(); | ||
client.set(null, {}, 1000, (err) => { | ||
client.set(null, {}, 1000, function (err) { | ||
@@ -235,9 +225,8 @@ expect(err instanceof Error).to.equal(true); | ||
it('returns error on get when using invalid key', (done) => { | ||
it('returns error on get when using invalid key', function (done) { | ||
const client = new Catbox.Client(Redis); | ||
client.start((err) => { | ||
var client = new Catbox.Client(Redis); | ||
client.start(function (err) { | ||
expect(err).to.not.exist(); | ||
client.get({}, (err) => { | ||
client.get({}, function (err) { | ||
@@ -250,9 +239,8 @@ expect(err instanceof Error).to.equal(true); | ||
it('returns error on drop when using invalid key', (done) => { | ||
it('returns error on drop when using invalid key', function (done) { | ||
const client = new Catbox.Client(Redis); | ||
client.start((err) => { | ||
var client = new Catbox.Client(Redis); | ||
client.start(function (err) { | ||
expect(err).to.not.exist(); | ||
client.drop({}, (err) => { | ||
client.drop({}, function (err) { | ||
@@ -265,9 +253,8 @@ expect(err instanceof Error).to.equal(true); | ||
it('returns error on set when using invalid key', (done) => { | ||
it('returns error on set when using invalid key', function (done) { | ||
const client = new Catbox.Client(Redis); | ||
client.start((err) => { | ||
var client = new Catbox.Client(Redis); | ||
client.start(function (err) { | ||
expect(err).to.not.exist(); | ||
client.set({}, {}, 1000, (err) => { | ||
client.set({}, {}, 1000, function (err) { | ||
@@ -280,10 +267,9 @@ expect(err instanceof Error).to.equal(true); | ||
it('ignores set when using non-positive ttl value', (done) => { | ||
it('ignores set when using non-positive ttl value', function (done) { | ||
const client = new Catbox.Client(Redis); | ||
client.start((err) => { | ||
var client = new Catbox.Client(Redis); | ||
client.start(function (err) { | ||
expect(err).to.not.exist(); | ||
const key = { id: 'x', segment: 'test' }; | ||
client.set(key, 'y', 0, (err) => { | ||
var key = { id: 'x', segment: 'test' }; | ||
client.set(key, 'y', 0, function (err) { | ||
@@ -296,9 +282,8 @@ expect(err).to.not.exist(); | ||
it('returns error on drop when using null key', (done) => { | ||
it('returns error on drop when using null key', function (done) { | ||
const client = new Catbox.Client(Redis); | ||
client.start((err) => { | ||
var client = new Catbox.Client(Redis); | ||
client.start(function (err) { | ||
expect(err).to.not.exist(); | ||
client.drop(null, (err) => { | ||
client.drop(null, function (err) { | ||
@@ -311,8 +296,8 @@ expect(err instanceof Error).to.equal(true); | ||
it('returns error on get when stopped', (done) => { | ||
it('returns error on get when stopped', function (done) { | ||
const client = new Catbox.Client(Redis); | ||
var client = new Catbox.Client(Redis); | ||
client.stop(); | ||
const key = { id: 'x', segment: 'test' }; | ||
client.connection.get(key, (err, result) => { | ||
var key = { id: 'x', segment: 'test' }; | ||
client.connection.get(key, function (err, result) { | ||
@@ -325,8 +310,8 @@ expect(err).to.exist(); | ||
it('returns error on set when stopped', (done) => { | ||
it('returns error on set when stopped', function (done) { | ||
const client = new Catbox.Client(Redis); | ||
var client = new Catbox.Client(Redis); | ||
client.stop(); | ||
const key = { id: 'x', segment: 'test' }; | ||
client.connection.set(key, 'y', 1, (err) => { | ||
var key = { id: 'x', segment: 'test' }; | ||
client.connection.set(key, 'y', 1, function (err) { | ||
@@ -338,8 +323,8 @@ expect(err).to.exist(); | ||
it('returns error on drop when stopped', (done) => { | ||
it('returns error on drop when stopped', function (done) { | ||
const client = new Catbox.Client(Redis); | ||
var client = new Catbox.Client(Redis); | ||
client.stop(); | ||
const key = { id: 'x', segment: 'test' }; | ||
client.connection.drop(key, (err) => { | ||
var key = { id: 'x', segment: 'test' }; | ||
client.connection.drop(key, function (err) { | ||
@@ -351,10 +336,10 @@ expect(err).to.exist(); | ||
it('returns error on missing segment name', (done) => { | ||
it('returns error on missing segment name', function (done) { | ||
const config = { | ||
var config = { | ||
expiresIn: 50000 | ||
}; | ||
const fn = () => { | ||
var fn = function () { | ||
const client = new Catbox.Client(Redis); | ||
var client = new Catbox.Client(Redis); | ||
new Catbox.Policy(config, client, ''); | ||
@@ -366,10 +351,10 @@ }; | ||
it('returns error on bad segment name', (done) => { | ||
it('returns error on bad segment name', function (done) { | ||
const config = { | ||
var config = { | ||
expiresIn: 50000 | ||
}; | ||
const fn = () => { | ||
var fn = function () { | ||
const client = new Catbox.Client(Redis); | ||
var client = new Catbox.Client(Redis); | ||
new Catbox.Policy(config, client, 'a\0b'); | ||
@@ -381,7 +366,7 @@ }; | ||
it('returns error when cache item dropped while stopped', (done) => { | ||
it('returns error when cache item dropped while stopped', function (done) { | ||
const client = new Catbox.Client(Redis); | ||
var client = new Catbox.Client(Redis); | ||
client.stop(); | ||
client.drop('a', (err) => { | ||
client.drop('a', function (err) { | ||
@@ -393,7 +378,7 @@ expect(err).to.exist(); | ||
describe('start()', () => { | ||
describe('#start', function () { | ||
it('sets client to when the connection succeeds', (done) => { | ||
it('sets client to when the connection succeeds', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -403,5 +388,5 @@ port: 6379 | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.start((err) => { | ||
redis.start(function (err) { | ||
@@ -414,5 +399,5 @@ expect(err).to.not.exist(); | ||
it('reuses the client when a connection is already started', (done) => { | ||
it('reuses the client when a connection is already started', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -422,10 +407,10 @@ port: 6379 | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.start((err) => { | ||
redis.start(function (err) { | ||
expect(err).to.not.exist(); | ||
const client = redis.client; | ||
var client = redis.client; | ||
redis.start(() => { | ||
redis.start(function () { | ||
@@ -438,5 +423,5 @@ expect(client).to.equal(redis.client); | ||
it('returns an error when connection fails', (done) => { | ||
it('returns an error when connection fails', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -446,5 +431,5 @@ port: 6380 | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.start((err) => { | ||
redis.start(function (err) { | ||
@@ -458,5 +443,5 @@ expect(err).to.exist(); | ||
it('sends auth command when password is provided', (done) => { | ||
it('sends auth command when password is provided', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -467,5 +452,5 @@ port: 6379, | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
const log = console.log; | ||
var log = console.log; | ||
console.log = function (message) { | ||
@@ -477,3 +462,3 @@ | ||
redis.start((err) => { | ||
redis.start(function (err) { | ||
@@ -485,5 +470,5 @@ expect(err).to.not.exist(); | ||
it('fails in error when auth is not correct', (done) => { | ||
it('fails in error when auth is not correct', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -494,5 +479,5 @@ port: 6378, | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.start((err) => { | ||
redis.start(function (err) { | ||
@@ -506,5 +491,5 @@ expect(err).to.exist(); | ||
it('success when auth is correct', (done) => { | ||
it('success when auth is correct', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -515,3 +500,3 @@ port: 6378, | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
@@ -521,5 +506,5 @@ redis.start(done); | ||
it('sends select command when database is provided', (done) => { | ||
it('sends select command when database is provided', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -530,8 +515,8 @@ port: 6379, | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.start(() => {}); | ||
redis.start(function () {}); | ||
// redis.client.selected_db gets updated after the callback | ||
setTimeout(() => { | ||
setTimeout(function () { | ||
@@ -543,14 +528,14 @@ expect(redis.client.selected_db).to.equal(1); | ||
it('connects to a unix domain socket when one is provided.', (done) => { | ||
it('connects to a unix domain socket when one is provided.', function (done) { | ||
const options = { | ||
var options = { | ||
socket: '/tmp/redis.sock' | ||
}; | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.start((err) => { | ||
redis.start(function (err) { | ||
expect(err).to.not.exist(); | ||
const client = redis.client; | ||
var client = redis.client; | ||
expect(client).to.exist(); | ||
@@ -563,5 +548,5 @@ expect(client.connected).to.equal(true); | ||
it('does not stops the client on error post connection', (done) => { | ||
it('does not stops the client on error post connection', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -571,5 +556,5 @@ port: 6379 | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.start((err) => { | ||
redis.start(function (err) { | ||
@@ -586,7 +571,7 @@ expect(err).to.not.exist(); | ||
describe('isReady()', () => { | ||
describe('#isReady', function () { | ||
it('returns true when when connected', (done) => { | ||
it('returns true when when connected', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -596,5 +581,5 @@ port: 6379 | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.start((err) => { | ||
redis.start(function (err) { | ||
@@ -610,5 +595,5 @@ expect(err).to.not.exist(); | ||
it('returns false when stopped', (done) => { | ||
it('returns false when stopped', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -618,5 +603,5 @@ port: 6379 | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.start((err) => { | ||
redis.start(function (err) { | ||
@@ -634,5 +619,5 @@ expect(err).to.not.exist(); | ||
it('returns false when disconnected', (done) => { | ||
it('returns false when disconnected', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -642,5 +627,5 @@ port: 6379 | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.start((err) => { | ||
redis.start(function (err) { | ||
@@ -660,7 +645,7 @@ expect(err).to.not.exist(); | ||
describe('validateSegmentName()', () => { | ||
describe('#validateSegmentName', function () { | ||
it('returns an error when the name is empty', (done) => { | ||
it('returns an error when the name is empty', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -670,5 +655,5 @@ port: 6379 | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
const result = redis.validateSegmentName(''); | ||
var result = redis.validateSegmentName(''); | ||
@@ -680,5 +665,5 @@ expect(result).to.be.instanceOf(Error); | ||
it('returns an error when the name has a null character', (done) => { | ||
it('returns an error when the name has a null character', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -688,5 +673,5 @@ port: 6379 | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
const result = redis.validateSegmentName('\0test'); | ||
var result = redis.validateSegmentName('\0test'); | ||
@@ -697,5 +682,5 @@ expect(result).to.be.instanceOf(Error); | ||
it('returns null when there aren\'t any errors', (done) => { | ||
it('returns null when there aren\'t any errors', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -705,5 +690,5 @@ port: 6379 | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
const result = redis.validateSegmentName('valid'); | ||
var result = redis.validateSegmentName('valid'); | ||
@@ -716,7 +701,7 @@ expect(result).to.not.be.instanceOf(Error); | ||
describe('get()', () => { | ||
describe('#get', function () { | ||
it('passes an error to the callback when the connection is closed', (done) => { | ||
it('passes an error to the callback when the connection is closed', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -726,5 +711,5 @@ port: 6379 | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.get('test', (err) => { | ||
redis.get('test', function (err) { | ||
@@ -738,5 +723,5 @@ expect(err).to.exist(); | ||
it('passes an error to the callback when there is an error returned from getting an item', (done) => { | ||
it('passes an error to the callback when there is an error returned from getting an item', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -746,3 +731,3 @@ port: 6379 | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.client = { | ||
@@ -755,3 +740,3 @@ get: function (item, callback) { | ||
redis.get('test', (err) => { | ||
redis.get('test', function (err) { | ||
@@ -764,5 +749,5 @@ expect(err).to.exist(); | ||
it('passes an error to the callback when there is an error parsing the result', (done) => { | ||
it('passes an error to the callback when there is an error parsing the result', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -772,3 +757,3 @@ port: 6379 | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.client = { | ||
@@ -781,3 +766,3 @@ get: function (item, callback) { | ||
redis.get('test', (err) => { | ||
redis.get('test', function (err) { | ||
@@ -790,5 +775,5 @@ expect(err).to.exist(); | ||
it('passes an error to the callback when there is an error with the envelope structure (stored)', (done) => { | ||
it('passes an error to the callback when there is an error with the envelope structure (stored)', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -798,3 +783,3 @@ port: 6379 | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.client = { | ||
@@ -807,3 +792,3 @@ get: function (item, callback) { | ||
redis.get('test', (err) => { | ||
redis.get('test', function (err) { | ||
@@ -816,5 +801,5 @@ expect(err).to.exist(); | ||
it('passes an error to the callback when there is an error with the envelope structure (item)', (done) => { | ||
it('passes an error to the callback when there is an error with the envelope structure (item)', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -824,3 +809,3 @@ port: 6379 | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.client = { | ||
@@ -833,3 +818,3 @@ get: function (item, callback) { | ||
redis.get('test', (err) => { | ||
redis.get('test', function (err) { | ||
@@ -842,5 +827,5 @@ expect(err).to.exist(); | ||
it('is able to retrieve an object thats stored when connection is started', (done) => { | ||
it('is able to retrieve an object thats stored when connection is started', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -850,3 +835,3 @@ port: 6379, | ||
}; | ||
const key = { | ||
var key = { | ||
id: 'test', | ||
@@ -856,10 +841,10 @@ segment: 'test' | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.start(() => { | ||
redis.start(function () { | ||
redis.set(key, 'myvalue', 200, (err) => { | ||
redis.set(key, 'myvalue', 200, function (err) { | ||
expect(err).to.not.exist(); | ||
redis.get(key, (err, result) => { | ||
redis.get(key, function (err, result) { | ||
@@ -874,5 +859,5 @@ expect(err).to.not.exist(); | ||
it('returns null when unable to find the item', (done) => { | ||
it('returns null when unable to find the item', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -882,3 +867,3 @@ port: 6379, | ||
}; | ||
const key = { | ||
var key = { | ||
id: 'notfound', | ||
@@ -888,7 +873,7 @@ segment: 'notfound' | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.start(() => { | ||
redis.start(function () { | ||
redis.get(key, (err, result) => { | ||
redis.get(key, function (err, result) { | ||
@@ -903,7 +888,7 @@ expect(err).to.not.exist(); | ||
describe('set()', () => { | ||
describe('#set', function () { | ||
it('passes an error to the callback when the connection is closed', (done) => { | ||
it('passes an error to the callback when the connection is closed', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -913,5 +898,5 @@ port: 6379 | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.set('test1', 'test1', 3600, (err) => { | ||
redis.set('test1', 'test1', 3600, function (err) { | ||
@@ -925,5 +910,5 @@ expect(err).to.exist(); | ||
it('passes an error to the callback when there is an error returned from setting an item', (done) => { | ||
it('passes an error to the callback when there is an error returned from setting an item', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -933,3 +918,3 @@ port: 6379 | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.client = { | ||
@@ -942,3 +927,3 @@ set: function (key, item, callback) { | ||
redis.set('test', 'test', 3600, (err) => { | ||
redis.set('test', 'test', 3600, function (err) { | ||
@@ -952,7 +937,7 @@ expect(err).to.exist(); | ||
describe('drop()', () => { | ||
describe('#drop', function () { | ||
it('passes an error to the callback when the connection is closed', (done) => { | ||
it('passes an error to the callback when the connection is closed', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -962,5 +947,5 @@ port: 6379 | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.drop('test2', (err) => { | ||
redis.drop('test2', function (err) { | ||
@@ -974,5 +959,5 @@ expect(err).to.exist(); | ||
it('deletes the item from redis', (done) => { | ||
it('deletes the item from redis', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -982,3 +967,3 @@ port: 6379 | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.client = { | ||
@@ -991,3 +976,3 @@ del: function (key, callback) { | ||
redis.drop('test', (err) => { | ||
redis.drop('test', function (err) { | ||
@@ -1000,13 +985,13 @@ expect(err).to.not.exist(); | ||
describe('generateKey()', () => { | ||
describe('generateKey()', function () { | ||
it('generates the storage key from a given catbox key', (done) => { | ||
it('generates the storage key from a given catbox key', function (done) { | ||
const options = { | ||
var options = { | ||
partition: 'foo' | ||
}; | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
const key = { | ||
var key = { | ||
id: 'bar', | ||
@@ -1020,9 +1005,9 @@ segment: 'baz' | ||
it('generates the storage key from a given catbox key without partition', (done) => { | ||
it('generates the storage key from a given catbox key without partition', function (done) { | ||
const options = {}; | ||
var options = {}; | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
const key = { | ||
var key = { | ||
id: 'bar', | ||
@@ -1037,7 +1022,7 @@ segment: 'baz' | ||
describe('stop()', () => { | ||
describe('#stop', function () { | ||
it('sets the client to null', (done) => { | ||
it('sets the client to null', function (done) { | ||
const options = { | ||
var options = { | ||
host: '127.0.0.1', | ||
@@ -1047,5 +1032,5 @@ port: 6379 | ||
const redis = new Redis(options); | ||
var redis = new Redis(options); | ||
redis.start(() => { | ||
redis.start(function () { | ||
@@ -1052,0 +1037,0 @@ expect(redis.client).to.exist(); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34898
30
879
+ Addedhoek@2.16.3(transitive)
- Removedhoek@3.0.4(transitive)
Updatedhoek@2.x.x