From 88d148ac6a65e815c60cf10ec06cfceb1bb0ef8e Mon Sep 17 00:00:00 2001 From: sqrt Date: Fri, 30 Oct 2015 12:09:18 -0700 Subject: [PATCH 01/14] Fix BRPOP --- .codeclimate.yml | 10 +++ .gitignore | 3 +- .travis.yml | 17 +++++ README.md | 6 ++ coffeelint.json | 135 ++++++++++++++++++++++++++++++++++++++ index.js | 3 +- package.json | 14 ++++ test/mocha.opts | 5 ++ test/redis-ns-spec.coffee | 11 ++++ test/test_helper.coffee | 8 +++ 10 files changed, 209 insertions(+), 3 deletions(-) create mode 100644 .codeclimate.yml create mode 100644 .travis.yml create mode 100644 coffeelint.json create mode 100644 test/mocha.opts create mode 100644 test/redis-ns-spec.coffee create mode 100644 test/test_helper.coffee diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 0000000..6c12698 --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,10 @@ +engines: + coffeelint: + enabled: true + +ratings: + paths: + - src/** + +exclude_paths: + - test/**/* diff --git a/.gitignore b/.gitignore index bbf787b..875d6d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store -node_modules \ No newline at end of file +node_modules +coverage diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b52d99c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,17 @@ +language: node_js +node_js: +- '0.11' +addons: + code_climate: + repo_token: +before_script: + - npm install -g codeclimate-test-reporter +after_script: +- codeclimate-test-reporter < coverage/lcov.info +deploy: + provider: npm + email: serveradmin@octoblu.com + api_key: + on: + tags: true + branches: true diff --git a/README.md b/README.md index 5dd3ddf..047306c 100644 --- a/README.md +++ b/README.md @@ -42,3 +42,9 @@ Until then: Feel free to play around with it, learn from it. npm install redis-ns + +[![Build Status](https://travis-ci.org/octoblu/redis-ns.svg?branch=master)](https://travis-ci.org/octoblu/redis-ns) +[![Code Climate](https://codeclimate.com/github/octoblu/redis-ns/badges/gpa.svg)](https://codeclimate.com/github/octoblu/redis-ns) +[![Test Coverage](https://codeclimate.com/github/octoblu/redis-ns/badges/coverage.svg)](https://codeclimate.com/github/octoblu/redis-ns) +[![npm version](https://badge.fury.io/js/redis-ns.svg)](http://badge.fury.io/js/redis-ns) +[![Gitter](https://badges.gitter.im/octoblu/help.svg)](https://gitter.im/octoblu/help) diff --git a/coffeelint.json b/coffeelint.json new file mode 100644 index 0000000..d573a61 --- /dev/null +++ b/coffeelint.json @@ -0,0 +1,135 @@ +{ + "arrow_spacing": { + "level": "ignore" + }, + "braces_spacing": { + "level": "ignore", + "spaces": 0, + "empty_object_spaces": 0 + }, + "camel_case_classes": { + "level": "error" + }, + "coffeescript_error": { + "level": "error" + }, + "colon_assignment_spacing": { + "level": "ignore", + "spacing": { + "left": 0, + "right": 0 + } + }, + "cyclomatic_complexity": { + "value": 10, + "level": "warn" + }, + "duplicate_key": { + "level": "error" + }, + "empty_constructor_needs_parens": { + "level": "ignore" + }, + "ensure_comprehensions": { + "level": "warn" + }, + "eol_last": { + "level": "ignore" + }, + "indentation": { + "value": 2, + "level": "error" + }, + "line_endings": { + "level": "ignore", + "value": "unix" + }, + "max_line_length": { + "value": 120, + "level": "error", + "limitComments": true + }, + "missing_fat_arrows": { + "level": "ignore", + "is_strict": false + }, + "newlines_after_classes": { + "value": 3, + "level": "ignore" + }, + "no_backticks": { + "level": "error" + }, + "no_debugger": { + "level": "warn", + "console": false + }, + "no_empty_functions": { + "level": "ignore" + }, + "no_empty_param_list": { + "level": "ignore" + }, + "no_implicit_braces": { + "level": "ignore", + "strict": true + }, + "no_implicit_parens": { + "strict": true, + "level": "ignore" + }, + "no_interpolation_in_single_quotes": { + "level": "ignore" + }, + "no_nested_string_interpolation": { + "level": "warn" + }, + "no_plusplus": { + "level": "ignore" + }, + "no_private_function_fat_arrows": { + "level": "warn" + }, + "no_stand_alone_at": { + "level": "ignore" + }, + "no_tabs": { + "level": "error" + }, + "no_this": { + "level": "ignore" + }, + "no_throwing_strings": { + "level": "error" + }, + "no_trailing_semicolons": { + "level": "error" + }, + "no_trailing_whitespace": { + "level": "error", + "allowed_in_comments": false, + "allowed_in_empty_lines": true + }, + "no_unnecessary_double_quotes": { + "level": "ignore" + }, + "no_unnecessary_fat_arrows": { + "level": "ignore" + }, + "non_empty_constructor_needs_parens": { + "level": "ignore" + }, + "prefer_english_operator": { + "level": "ignore", + "doubleNotLevel": "ignore" + }, + "space_operators": { + "level": "ignore" + }, + "spacing_after_comma": { + "level": "ignore" + }, + "transform_messes_up_line_numbers": { + "level": "warn" + } +} diff --git a/index.js b/index.js index 72aebaa..b402b1f 100644 --- a/index.js +++ b/index.js @@ -51,7 +51,7 @@ RedisNS.prototype['blpop'] = function() { }; RedisNS.prototype['brpop'] = function() { - for(var i=0 ; i < (arguments.length-1) ; i++) { + for(var i=0 ; i < (arguments.length-2) ; i++) { arguments[i] = this.namespace + ':' + arguments[i]; } return this.redisClient['brpop'].apply(this.redisClient, arguments); @@ -623,4 +623,3 @@ RedisNS.prototype['zunionstore'] = function() { } return this.redisClient['zunionstore'].apply(this.redisClient, arguments); }; - diff --git a/package.json b/package.json index d9c361f..32af05d 100644 --- a/package.json +++ b/package.json @@ -30,5 +30,19 @@ "main": "./index", "engines": { "node": ">=0.8.0" + }, + "devDependencies": { + "chai": "^3.4.0", + "coffee-coverage": "^0.7.0", + "coffee-script": "^1.10.0", + "fakeredis": "^0.3.4", + "istanbul": "^0.4.0", + "mocha": "^2.3.3", + "mocha-istanbul": "^0.2.0", + "sinon": "^1.17.2", + "sinon-chai": "^2.8.0" + }, + "scripts": { + "test": "istanbul cover _mocha -- -R spec" } } diff --git a/test/mocha.opts b/test/mocha.opts new file mode 100644 index 0000000..a7d547e --- /dev/null +++ b/test/mocha.opts @@ -0,0 +1,5 @@ +--recursive +--compilers coffee:coffee-script +--require coffee-script/register +--require test/test_helper.coffee +--require coffee-coverage/register-istanbul diff --git a/test/redis-ns-spec.coffee b/test/redis-ns-spec.coffee new file mode 100644 index 0000000..67b70f0 --- /dev/null +++ b/test/redis-ns-spec.coffee @@ -0,0 +1,11 @@ +redis = require 'fakeredis' +RedisNS = require '../index.js' + +describe 'RedisNS', -> + describe '->brpop', -> + beforeEach (done)-> + @sut = new RedisNS 'ns', redis.createClient() + @sut.brpop 'list1', 'list2', 1, (@error) => done() + + it 'should not throw an error', -> + expect(@error).not.to.exist diff --git a/test/test_helper.coffee b/test/test_helper.coffee new file mode 100644 index 0000000..93ff593 --- /dev/null +++ b/test/test_helper.coffee @@ -0,0 +1,8 @@ +chai = require 'chai' +sinon = require 'sinon' +sinonChai = require 'sinon-chai' + +chai.use sinonChai + +global.expect = chai.expect +global.sinon = sinon From a3c9fffca7e50e58b302c95109ab9da4d5d53c3f Mon Sep 17 00:00:00 2001 From: sqrt Date: Fri, 30 Oct 2015 12:11:39 -0700 Subject: [PATCH 02/14] Add @octoblu namespace --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 32af05d..0278443 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "redis-ns", + "name": "@octoblu/redis-ns", "version": "0.1.1", "description": "This module enables you to create Redis namespaces.", "keywords": [ From eab0face9e3e1db286eab1b6185424f4cd6905c6 Mon Sep 17 00:00:00 2001 From: Square Root of Saturn Date: Thu, 10 Dec 2015 10:31:56 -0700 Subject: [PATCH 03/14] use latest redis --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 0278443..683ce1d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@octoblu/redis-ns", - "version": "0.1.1", + "version": "0.1.2", "description": "This module enables you to create Redis namespaces.", "keywords": [ "redis", @@ -16,7 +16,7 @@ } ], "dependencies": { - "redis": "~0.9.0" + "redis": "^2.4.2" }, "repository": { "type": "git", From 66bfdd6fbcd410cd51b3c29d2c32e62313ad2a98 Mon Sep 17 00:00:00 2001 From: Sqrt of Saturn Date: Tue, 29 Dec 2015 08:32:57 -0700 Subject: [PATCH 04/14] fixed del callback --- index.js | 5 ++++- package.json | 2 +- test/redis-ns-spec.coffee | 8 ++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index b402b1f..efa7640 100644 --- a/index.js +++ b/index.js @@ -79,7 +79,10 @@ RedisNS.prototype['decrby'] = function() { }; RedisNS.prototype['del'] = function() { - for(var i=0 ; i < arguments.length ; i++) { + for(var i=0 ; i < arguments.length; i++) { + if(typeof arguments[i] === 'function'){ + break; + } arguments[i] = this.namespace + ':' + arguments[i]; } return this.redisClient['del'].apply(this.redisClient, arguments); diff --git a/package.json b/package.json index 683ce1d..9e9230c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@octoblu/redis-ns", - "version": "0.1.2", + "version": "0.1.3", "description": "This module enables you to create Redis namespaces.", "keywords": [ "redis", diff --git a/test/redis-ns-spec.coffee b/test/redis-ns-spec.coffee index 67b70f0..1561660 100644 --- a/test/redis-ns-spec.coffee +++ b/test/redis-ns-spec.coffee @@ -9,3 +9,11 @@ describe 'RedisNS', -> it 'should not throw an error', -> expect(@error).not.to.exist + + describe '->del', -> + beforeEach (done)-> + @sut = new RedisNS 'ns', redis.createClient() + @sut.del 'hello', (@error) => done() + + it 'should not throw an error', -> + expect(@error).not.to.exist From 4d78f923486e4969c82d7b1a4633cf792a624d6c Mon Sep 17 00:00:00 2001 From: Sqrt of Saturn Date: Tue, 12 Jan 2016 13:14:12 -0700 Subject: [PATCH 05/14] v1.0.0 do not stringify on publish --- index.js | 1 - package.json | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index efa7640..511eefe 100644 --- a/index.js +++ b/index.js @@ -342,7 +342,6 @@ RedisNS.prototype['pttl'] = function() { RedisNS.prototype['publish'] = function() { arguments[0] = this.namespace + ':' + arguments[0]; - arguments[1] = JSON.stringify(arguments[1]); return this.redisClient['publish'].apply(this.redisClient, arguments); }; diff --git a/package.json b/package.json index 9e9230c..8f9a5e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@octoblu/redis-ns", - "version": "0.1.3", + "version": "1.0.0", "description": "This module enables you to create Redis namespaces.", "keywords": [ "redis", @@ -45,4 +45,4 @@ "scripts": { "test": "istanbul cover _mocha -- -R spec" } -} +} \ No newline at end of file From 4641a8c0096eaa00e00f4693d67e4a5b03ba2080 Mon Sep 17 00:00:00 2001 From: Sqrt of Saturn Date: Tue, 12 Jan 2016 13:20:17 -0700 Subject: [PATCH 06/14] v1.0.1 add npmignore --- .npmignore | 34 ++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .npmignore diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..5d8965d --- /dev/null +++ b/.npmignore @@ -0,0 +1,34 @@ +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# Commenting this out is preferred by some people, see +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- +node_modules + +# Users Environment Variables +.lock-wscript +meshblu.json +tmp +devices +.npmrc +*.sublime-workspace +.git diff --git a/package.json b/package.json index 8f9a5e6..75ebd12 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@octoblu/redis-ns", - "version": "1.0.0", + "version": "1.0.1", "description": "This module enables you to create Redis namespaces.", "keywords": [ "redis", From ffc16abf5ec80cc25138665d81f4256008d6103d Mon Sep 17 00:00:00 2001 From: sqrtofsaturn Date: Tue, 19 Jan 2016 11:55:24 -0700 Subject: [PATCH 07/14] v1.1.0 all functions are bound! no _.bindAll necessary --- index.js | 991 ++++++++++++++++++++++++++------------------------- package.json | 2 +- 2 files changed, 497 insertions(+), 496 deletions(-) diff --git a/index.js b/index.js index 511eefe..b1cd21d 100644 --- a/index.js +++ b/index.js @@ -4,13 +4,13 @@ var redis = require('redis'); var RedisNS = function(namespace, redisClient) { var self = this; - this.namespace = namespace; - this.redisClient = redisClient; + self.namespace = namespace; + self.redisClient = redisClient; // "inherit" missing functions from redisClient for(var i in redisClient) { - if(typeof this[i] !== 'function') { - this[i] = redisClient[i]; + if(typeof self[i] !== 'function') { + self[i] = redisClient[i]; } } @@ -20,608 +20,609 @@ var RedisNS = function(namespace, redisClient) { arguments[1] = arguments[1].replace(self.namespace+':', ''); arguments[2] = JSON.parse(arguments[2]); } - redis.RedisClient.prototype.emit.apply(this, arguments); + redis.RedisClient.prototype.emit.apply(self, arguments); }; -}; -util.inherits(RedisNS, redis.RedisClient); -module.exports = RedisNS; -RedisNS.prototype['append'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['append'].apply(this.redisClient, arguments); -}; + self['append'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['append'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['bitcount'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['bitcount'].apply(this.redisClient, arguments); -}; + self['bitcount'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['bitcount'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['bitop'] = function() { - for(var i=1 ; i < arguments.length ; i++) { - arguments[i] = this.namespace + ':' + arguments[i]; - } - return this.redisClient['bitop'].apply(this.redisClient, arguments); -}; + self['bitop'] = function() { + for(var i=1 ; i < arguments.length ; i++) { + arguments[i] = self.namespace + ':' + arguments[i]; + } + return self.redisClient['bitop'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['blpop'] = function() { - for(var i=0 ; i < (arguments.length-1) ; i++) { - arguments[i] = this.namespace + ':' + arguments[i]; - } - return this.redisClient['blpop'].apply(this.redisClient, arguments); -}; + self['blpop'] = function() { + for(var i=0 ; i < (arguments.length-1) ; i++) { + arguments[i] = self.namespace + ':' + arguments[i]; + } + return self.redisClient['blpop'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['brpop'] = function() { - for(var i=0 ; i < (arguments.length-2) ; i++) { - arguments[i] = this.namespace + ':' + arguments[i]; - } - return this.redisClient['brpop'].apply(this.redisClient, arguments); -}; + self['brpop'] = function() { + for(var i=0 ; i < (arguments.length-2) ; i++) { + arguments[i] = self.namespace + ':' + arguments[i]; + } + return self.redisClient['brpop'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['brpoplpush'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - arguments[1] = this.namespace + ':' + arguments[1]; - return this.redisClient['brpoplpush'].apply(this.redisClient, arguments); -}; + self['brpoplpush'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + arguments[1] = self.namespace + ':' + arguments[1]; + return self.redisClient['brpoplpush'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['debug object'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['debug object'].apply(this.redisClient, arguments); -}; + self['debug object'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['debug object'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['decr'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['decr'].apply(this.redisClient, arguments); -}; + self['decr'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['decr'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['decrby'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['decrby'].apply(this.redisClient, arguments); -}; + self['decrby'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['decrby'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['del'] = function() { - for(var i=0 ; i < arguments.length; i++) { - if(typeof arguments[i] === 'function'){ - break; + self['del'] = function() { + for(var i=0 ; i < arguments.length; i++) { + if(typeof arguments[i] === 'function'){ + break; + } + arguments[i] = self.namespace + ':' + arguments[i]; } - arguments[i] = this.namespace + ':' + arguments[i]; - } - return this.redisClient['del'].apply(this.redisClient, arguments); -}; + return self.redisClient['del'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['dump'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['dump'].apply(this.redisClient, arguments); -}; + self['dump'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['dump'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['eval'] = function() { - for(var i=2, lastKeyIndex = (parseInt(arguments[1])+1) ; i <= lastKeyIndex ; i++) { - arguments[i] = this.namespace + ':' + arguments[i]; - } - return this.redisClient['eval'].apply(this.redisClient, arguments); -}; + self['eval'] = function() { + for(var i=2, lastKeyIndex = (parseInt(arguments[1])+1) ; i <= lastKeyIndex ; i++) { + arguments[i] = self.namespace + ':' + arguments[i]; + } + return self.redisClient['eval'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['evalsha'] = function() { - for(var i=2, lastKeyIndex = (parseInt(arguments[1])+1) ; i <= lastKeyIndex ; i++) { - arguments[i] = this.namespace + ':' + arguments[i]; - } - return this.redisClient['evalsha'].apply(this.redisClient, arguments); -}; + self['evalsha'] = function() { + for(var i=2, lastKeyIndex = (parseInt(arguments[1])+1) ; i <= lastKeyIndex ; i++) { + arguments[i] = self.namespace + ':' + arguments[i]; + } + return self.redisClient['evalsha'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['exists'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['exists'].apply(this.redisClient, arguments); -}; + self['exists'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['exists'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['expire'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['expire'].apply(this.redisClient, arguments); -}; + self['expire'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['expire'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['expireat'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['expireat'].apply(this.redisClient, arguments); -}; + self['expireat'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['expireat'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['get'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['get'].apply(this.redisClient, arguments); -}; + self['get'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['get'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['getbit'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['getbit'].apply(this.redisClient, arguments); -}; + self['getbit'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['getbit'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['getrange'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['getrange'].apply(this.redisClient, arguments); -}; + self['getrange'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['getrange'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['getset'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['getset'].apply(this.redisClient, arguments); -}; + self['getset'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['getset'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['hdel'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['hdel'].apply(this.redisClient, arguments); -}; + self['hdel'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['hdel'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['hexists'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['hexists'].apply(this.redisClient, arguments); -}; + self['hexists'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['hexists'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['hget'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['hget'].apply(this.redisClient, arguments); -}; + self['hget'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['hget'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['hgetall'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['hgetall'].apply(this.redisClient, arguments); -}; + self['hgetall'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['hgetall'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['hincrby'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['hincrby'].apply(this.redisClient, arguments); -}; + self['hincrby'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['hincrby'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['hincrbyfloat'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['hincrbyfloat'].apply(this.redisClient, arguments); -}; + self['hincrbyfloat'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['hincrbyfloat'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['hkeys'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['hkeys'].apply(this.redisClient, arguments); -}; + self['hkeys'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['hkeys'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['hlen'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['hlen'].apply(this.redisClient, arguments); -}; + self['hlen'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['hlen'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['hmget'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['hmget'].apply(this.redisClient, arguments); -}; + self['hmget'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['hmget'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['hmset'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['hmset'].apply(this.redisClient, arguments); -}; + self['hmset'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['hmset'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['hset'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['hset'].apply(this.redisClient, arguments); -}; + self['hset'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['hset'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['hsetnx'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['hsetnx'].apply(this.redisClient, arguments); -}; + self['hsetnx'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['hsetnx'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['hvals'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['hvals'].apply(this.redisClient, arguments); -}; + self['hvals'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['hvals'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['incr'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['incr'].apply(this.redisClient, arguments); -}; + self['incr'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['incr'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['incrby'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['incrby'].apply(this.redisClient, arguments); -}; + self['incrby'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['incrby'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['incrbyfloat'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['incrbyfloat'].apply(this.redisClient, arguments); -}; + self['incrbyfloat'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['incrbyfloat'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['keys'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['keys'].apply(this.redisClient, arguments); -}; + self['keys'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['keys'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['lindex'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['lindex'].apply(this.redisClient, arguments); -}; + self['lindex'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['lindex'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['linsert'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['linsert'].apply(this.redisClient, arguments); -}; + self['linsert'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['linsert'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['llen'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['llen'].apply(this.redisClient, arguments); -}; + self['llen'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['llen'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['lpop'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['lpop'].apply(this.redisClient, arguments); -}; + self['lpop'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['lpop'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['lpush'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['lpush'].apply(this.redisClient, arguments); -}; + self['lpush'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['lpush'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['lpushx'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['lpushx'].apply(this.redisClient, arguments); -}; + self['lpushx'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['lpushx'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['lrange'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['lrange'].apply(this.redisClient, arguments); -}; + self['lrange'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['lrange'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['lrem'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['lrem'].apply(this.redisClient, arguments); -}; + self['lrem'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['lrem'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['lset'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['lset'].apply(this.redisClient, arguments); -}; + self['lset'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['lset'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['ltrim'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['ltrim'].apply(this.redisClient, arguments); -}; + self['ltrim'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['ltrim'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['mget'] = function() { - for(var i=0 ; i < arguments.length ; i++) { - arguments[i] = this.namespace + ':' + arguments[i]; - } - return this.redisClient['mget'].apply(this.redisClient, arguments); -}; + self['mget'] = function() { + for(var i=0 ; i < arguments.length ; i++) { + arguments[i] = self.namespace + ':' + arguments[i]; + } + return self.redisClient['mget'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['migrate'] = function() { - arguments[2] = this.namespace + ':' + arguments[2]; - return this.redisClient['migrate'].apply(this.redisClient, arguments); -}; + self['migrate'] = function() { + arguments[2] = self.namespace + ':' + arguments[2]; + return self.redisClient['migrate'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['move'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['move'].apply(this.redisClient, arguments); -}; + self['move'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['move'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['mset'] = function() { - for(var i=0 ; i < arguments.length ; i+=2) { - arguments[i] = this.namespace + ':' + arguments[i]; - } - return this.redisClient['mset'].apply(this.redisClient, arguments); -}; + self['mset'] = function() { + for(var i=0 ; i < arguments.length ; i+=2) { + arguments[i] = self.namespace + ':' + arguments[i]; + } + return self.redisClient['mset'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['msetnx'] = function() { - for(var i=0 ; i < arguments.length ; i+=2) { - arguments[i] = this.namespace + ':' + arguments[i]; - } - return this.redisClient['msetnx'].apply(this.redisClient, arguments); -}; + self['msetnx'] = function() { + for(var i=0 ; i < arguments.length ; i+=2) { + arguments[i] = self.namespace + ':' + arguments[i]; + } + return self.redisClient['msetnx'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['persist'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['persist'].apply(this.redisClient, arguments); -}; + self['persist'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['persist'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['pexpire'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['pexpire'].apply(this.redisClient, arguments); -}; + self['pexpire'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['pexpire'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['pexpireat'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['pexpireat'].apply(this.redisClient, arguments); -}; + self['pexpireat'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['pexpireat'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['psetex'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['psetex'].apply(this.redisClient, arguments); -}; + self['psetex'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['psetex'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['psubscribe'] = function() { - for(var i=0 ; i < arguments.length ; i++) { - arguments[i] = this.namespace + ':' + arguments[i]; - } - return this.redisClient['psubscribe'].apply(this.redisClient, arguments); -}; + self['psubscribe'] = function() { + for(var i=0 ; i < arguments.length ; i++) { + arguments[i] = self.namespace + ':' + arguments[i]; + } + return self.redisClient['psubscribe'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['pttl'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['pttl'].apply(this.redisClient, arguments); -}; + self['pttl'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['pttl'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['publish'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['publish'].apply(this.redisClient, arguments); -}; + self['publish'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['publish'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['punsubscribe'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['punsubscribe'].apply(this.redisClient, arguments); -}; + self['punsubscribe'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['punsubscribe'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['rename'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - arguments[1] = this.namespace + ':' + arguments[1]; - return this.redisClient['rename'].apply(this.redisClient, arguments); -}; + self['rename'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + arguments[1] = self.namespace + ':' + arguments[1]; + return self.redisClient['rename'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['renamenx'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - arguments[1] = this.namespace + ':' + arguments[1]; - return this.redisClient['renamenx'].apply(this.redisClient, arguments); -}; + self['renamenx'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + arguments[1] = self.namespace + ':' + arguments[1]; + return self.redisClient['renamenx'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['restore'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['restore'].apply(this.redisClient, arguments); -}; + self['restore'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['restore'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['rpop'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['rpop'].apply(this.redisClient, arguments); -}; + self['rpop'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['rpop'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['rpoplpush'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - arguments[1] = this.namespace + ':' + arguments[1]; - return this.redisClient['rpoplpush'].apply(this.redisClient, arguments); -}; + self['rpoplpush'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + arguments[1] = self.namespace + ':' + arguments[1]; + return self.redisClient['rpoplpush'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['rpush'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['rpush'].apply(this.redisClient, arguments); -}; + self['rpush'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['rpush'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['rpushx'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['rpushx'].apply(this.redisClient, arguments); -}; + self['rpushx'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['rpushx'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['sadd'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['sadd'].apply(this.redisClient, arguments); -}; + self['sadd'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['sadd'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['scard'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['scard'].apply(this.redisClient, arguments); -}; + self['scard'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['scard'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['sdiff'] = function() { - for(var i=0 ; i < arguments.length ; i++) { - arguments[i] = this.namespace + ':' + arguments[i]; - } - return this.redisClient['sdiff'].apply(this.redisClient, arguments); -}; + self['sdiff'] = function() { + for(var i=0 ; i < arguments.length ; i++) { + arguments[i] = self.namespace + ':' + arguments[i]; + } + return self.redisClient['sdiff'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['sdiffstore'] = function() { - for(var i=0 ; i < arguments.length ; i++) { - arguments[i] = this.namespace + ':' + arguments[i]; - } - return this.redisClient['sdiffstore'].apply(this.redisClient, arguments); -}; + self['sdiffstore'] = function() { + for(var i=0 ; i < arguments.length ; i++) { + arguments[i] = self.namespace + ':' + arguments[i]; + } + return self.redisClient['sdiffstore'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['set'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['set'].apply(this.redisClient, arguments); -}; + self['set'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['set'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['setbit'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['setbit'].apply(this.redisClient, arguments); -}; + self['setbit'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['setbit'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['setex'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['setex'].apply(this.redisClient, arguments); -}; + self['setex'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['setex'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['setnx'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['setnx'].apply(this.redisClient, arguments); -}; + self['setnx'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['setnx'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['setrange'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['setrange'].apply(this.redisClient, arguments); -}; + self['setrange'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['setrange'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['sinter'] = function() { - for(var i=0 ; i < arguments.length ; i++) { - arguments[i] = this.namespace + ':' + arguments[i]; - } - return this.redisClient['sinter'].apply(this.redisClient, arguments); -}; + self['sinter'] = function() { + for(var i=0 ; i < arguments.length ; i++) { + arguments[i] = self.namespace + ':' + arguments[i]; + } + return self.redisClient['sinter'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['sinterstore'] = function() { - for(var i=0 ; i < arguments.length ; i++) { - arguments[i] = this.namespace + ':' + arguments[i]; - } - return this.redisClient['sinterstore'].apply(this.redisClient, arguments); -}; + self['sinterstore'] = function() { + for(var i=0 ; i < arguments.length ; i++) { + arguments[i] = self.namespace + ':' + arguments[i]; + } + return self.redisClient['sinterstore'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['sismember'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['sismember'].apply(this.redisClient, arguments); -}; + self['sismember'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['sismember'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['smembers'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['smembers'].apply(this.redisClient, arguments); -}; + self['smembers'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['smembers'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['smove'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - arguments[1] = this.namespace + ':' + arguments[1]; - return this.redisClient['smove'].apply(this.redisClient, arguments); -}; + self['smove'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + arguments[1] = self.namespace + ':' + arguments[1]; + return self.redisClient['smove'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['sort'] = function() { - // This one probably needs some work!... - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['sort'].apply(this.redisClient, arguments); -}; + self['sort'] = function() { + // self one probably needs some work!... + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['sort'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['spop'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['spop'].apply(this.redisClient, arguments); -}; + self['spop'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['spop'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['srandmember'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['srandmember'].apply(this.redisClient, arguments); -}; + self['srandmember'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['srandmember'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['srem'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['srem'].apply(this.redisClient, arguments); -}; + self['srem'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['srem'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['strlen'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['strlen'].apply(this.redisClient, arguments); -}; + self['strlen'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['strlen'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['subscribe'] = function() { - for(var i=0 ; i < arguments.length ; i++) { - arguments[i] = this.namespace + ':' + arguments[i]; - } - return this.redisClient['subscribe'].apply(this.redisClient, arguments); -}; + self['subscribe'] = function() { + for(var i=0 ; i < arguments.length ; i++) { + arguments[i] = self.namespace + ':' + arguments[i]; + } + return self.redisClient['subscribe'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['sunion'] = function() { - for(var i=0 ; i < arguments.length ; i++) { - arguments[i] = this.namespace + ':' + arguments[i]; - } - return this.redisClient['sunion'].apply(this.redisClient, arguments); -}; + self['sunion'] = function() { + for(var i=0 ; i < arguments.length ; i++) { + arguments[i] = self.namespace + ':' + arguments[i]; + } + return self.redisClient['sunion'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['sunionstore'] = function() { - for(var i=0 ; i < arguments.length ; i++) { - arguments[i] = this.namespace + ':' + arguments[i]; - } - return this.redisClient['sunionstore'].apply(this.redisClient, arguments); -}; + self['sunionstore'] = function() { + for(var i=0 ; i < arguments.length ; i++) { + arguments[i] = self.namespace + ':' + arguments[i]; + } + return self.redisClient['sunionstore'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['ttl'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['ttl'].apply(this.redisClient, arguments); -}; + self['ttl'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['ttl'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['type'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['type'].apply(this.redisClient, arguments); -}; + self['type'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['type'].apply(self.redisClient, arguments); + }; + + self['unsubscribe'] = function() { + if(arguments.length > 0) { + for(var i=0 ; i < arguments.length ; i++) { + arguments[i] = self.namespace + ':' + arguments[i]; + } + } + return self.redisClient['unsubscribe'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['unsubscribe'] = function() { - if(arguments.length > 0) { + self['watch'] = function() { for(var i=0 ; i < arguments.length ; i++) { - arguments[i] = this.namespace + ':' + arguments[i]; + arguments[i] = self.namespace + ':' + arguments[i]; } - } - return this.redisClient['unsubscribe'].apply(this.redisClient, arguments); -}; + return self.redisClient['watch'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['watch'] = function() { - for(var i=0 ; i < arguments.length ; i++) { - arguments[i] = this.namespace + ':' + arguments[i]; - } - return this.redisClient['watch'].apply(this.redisClient, arguments); -}; + self['zadd'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['zadd'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['zadd'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['zadd'].apply(this.redisClient, arguments); -}; + self['zcard'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['zcard'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['zcard'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['zcard'].apply(this.redisClient, arguments); -}; + self['zcount'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['zcount'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['zcount'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['zcount'].apply(this.redisClient, arguments); -}; + self['zincrby'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['zincrby'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['zincrby'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['zincrby'].apply(this.redisClient, arguments); -}; + self['zinterstore'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + for(var i=2, lastKeyIndex = (parseInt(arguments[1])+1) ; i <= lastKeyIndex ; i++) { + arguments[i] = self.namespace + ':' + arguments[i]; + } + return self.redisClient['zinterstore'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['zinterstore'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - for(var i=2, lastKeyIndex = (parseInt(arguments[1])+1) ; i <= lastKeyIndex ; i++) { - arguments[i] = this.namespace + ':' + arguments[i]; - } - return this.redisClient['zinterstore'].apply(this.redisClient, arguments); -}; + self['zrange'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['zrange'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['zrange'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['zrange'].apply(this.redisClient, arguments); -}; + self['zrangebyscore'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['zrangebyscore'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['zrangebyscore'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['zrangebyscore'].apply(this.redisClient, arguments); -}; + self['zrank'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['zrank'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['zrank'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['zrank'].apply(this.redisClient, arguments); -}; + self['zrem'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['zrem'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['zrem'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['zrem'].apply(this.redisClient, arguments); -}; + self['zremrangebyrank'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['zremrangebyrank'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['zremrangebyrank'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['zremrangebyrank'].apply(this.redisClient, arguments); -}; + self['zremrangebyscore'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['zremrangebyscore'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['zremrangebyscore'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['zremrangebyscore'].apply(this.redisClient, arguments); -}; + self['zrevrange'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['zrevrange'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['zrevrange'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['zrevrange'].apply(this.redisClient, arguments); -}; + self['zrevrangebyscore'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['zrevrangebyscore'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['zrevrangebyscore'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['zrevrangebyscore'].apply(this.redisClient, arguments); -}; + self['zrevrank'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['zrevrank'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['zrevrank'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['zrevrank'].apply(this.redisClient, arguments); -}; + self['zscore'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + return self.redisClient['zscore'].apply(self.redisClient, arguments); + }; -RedisNS.prototype['zscore'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - return this.redisClient['zscore'].apply(this.redisClient, arguments); + self['zunionstore'] = function() { + arguments[0] = self.namespace + ':' + arguments[0]; + for(var i=2, lastKeyIndex = (parseInt(arguments[1])+1) ; i <= lastKeyIndex ; i++) { + arguments[i] = self.namespace + ':' + arguments[i]; + } + return self.redisClient['zunionstore'].apply(self.redisClient, arguments); + }; }; -RedisNS.prototype['zunionstore'] = function() { - arguments[0] = this.namespace + ':' + arguments[0]; - for(var i=2, lastKeyIndex = (parseInt(arguments[1])+1) ; i <= lastKeyIndex ; i++) { - arguments[i] = this.namespace + ':' + arguments[i]; - } - return this.redisClient['zunionstore'].apply(this.redisClient, arguments); -}; +util.inherits(RedisNS, redis.RedisClient); +module.exports = RedisNS; diff --git a/package.json b/package.json index 75ebd12..982fbf7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@octoblu/redis-ns", - "version": "1.0.1", + "version": "1.1.0", "description": "This module enables you to create Redis namespaces.", "keywords": [ "redis", From 750df5146c56f3e00e5438d4b6dab258ef418451 Mon Sep 17 00:00:00 2001 From: sqrtofsaturn Date: Tue, 19 Jan 2016 12:00:25 -0700 Subject: [PATCH 08/14] v1.1.1 4 travis --- .travis.yml | 8 +++----- package.json | 10 +++++----- test/mocha.opts | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index b52d99c..585b67c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,15 @@ language: node_js node_js: -- '0.11' -addons: - code_climate: - repo_token: +- '5' before_script: - - npm install -g codeclimate-test-reporter +- npm install -g codeclimate-test-reporter after_script: - codeclimate-test-reporter < coverage/lcov.info deploy: provider: npm email: serveradmin@octoblu.com api_key: + secure: LEihI84wv50wPLf8Ob2q9YNRo1znpi+t7ok9xdCxpeNZ6OyHLv0kswJFwrHh80Z5kKmhV/TOrGdvcZTNTR4p0K2begmiASW38h1vSqvq6NeqacBKRx4k/yqB4SN3QdB2q9xJ+22ZJb08jm3Y7P6poJJ2W9QpY3n5bKG0jlddmjdmqOdol7JUZx9K2n7alL4+/yhC2MiVZbn7Ou2M/MqXV1YExa+jMQcNpzRKhUK07Y4wog5eA1EM+S9+iTan6fW8ZdScIl/BxAm7HZfWfF+oHyyWwDPec6FHQczR4n25/0w13AvXevxkF4ofQgG32JjJpXNCf5LryBe9l9pjFJP3NRmCxrt3wy9lZ0tdY1LcymlT6eUN3g2F9Nj7TmNHojH5EANeVH8d/UEvdluVgU55Vawh+SemPWUc/IHSptuN8HqvUNE4aR1dfxbXaF1bvztiglgHiAEWBQrKuCXx3sLqAe5Wu4Ja8joyzn6sumvP6V1rOdTRQb4taFr/NpLCZ2gVi/ZmfU53TjUx9JwXOsK1whkTiCGP5KgKmdgVAoYD/Pdcw5LPd3hdyLvBKpZHH6qfL6c7Lo9Wq+aM2j5Z7GMQOr/HjD4Z03B1o2ygGW/SdKFhoR6DDuL8+HTIAqicQ8heEjEB0hV3SelY5URcXLQOxcV7hSxlfIhfH8If9PzelP4= on: tags: true branches: true diff --git a/package.json b/package.json index 982fbf7..05e2551 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@octoblu/redis-ns", - "version": "1.1.0", + "version": "1.1.1", "description": "This module enables you to create Redis namespaces.", "keywords": [ "redis", @@ -32,17 +32,17 @@ "node": ">=0.8.0" }, "devDependencies": { - "chai": "^3.4.0", + "chai": "^3.4.1", "coffee-coverage": "^0.7.0", "coffee-script": "^1.10.0", "fakeredis": "^0.3.4", - "istanbul": "^0.4.0", - "mocha": "^2.3.3", + "istanbul": "^0.4.2", + "mocha": "^2.3.4", "mocha-istanbul": "^0.2.0", "sinon": "^1.17.2", "sinon-chai": "^2.8.0" }, "scripts": { - "test": "istanbul cover _mocha -- -R spec" + "test": "istanbul cover _mocha -- -R spec --require coffee-coverage/register-istanbul" } } \ No newline at end of file diff --git a/test/mocha.opts b/test/mocha.opts index a7d547e..9e97039 100644 --- a/test/mocha.opts +++ b/test/mocha.opts @@ -1,5 +1,5 @@ +--bail --recursive --compilers coffee:coffee-script --require coffee-script/register --require test/test_helper.coffee ---require coffee-coverage/register-istanbul From 51a537ac3d9a83018b5e50594d431ca22b0cacdf Mon Sep 17 00:00:00 2001 From: sqrtofsaturn Date: Tue, 19 Jan 2016 12:02:13 -0700 Subject: [PATCH 09/14] v1.1.2 4 travis --- .travis.yml | 5 +---- package.json | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 585b67c..67d7147 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,7 @@ language: node_js node_js: - '5' -before_script: -- npm install -g codeclimate-test-reporter -after_script: -- codeclimate-test-reporter < coverage/lcov.info + deploy: provider: npm email: serveradmin@octoblu.com diff --git a/package.json b/package.json index 05e2551..e1aa8fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@octoblu/redis-ns", - "version": "1.1.1", + "version": "1.1.2", "description": "This module enables you to create Redis namespaces.", "keywords": [ "redis", From 443976e7bb19fccb7ee95d7f51d35d17c0ebaeca Mon Sep 17 00:00:00 2001 From: sqrtofsaturn Date: Tue, 19 Jan 2016 14:05:59 -0700 Subject: [PATCH 10/14] v1.2.0 fix pub/sub to de-namespace the channel --- index.js | 28 +++++++++++++--------------- package.json | 3 ++- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index b1cd21d..b97218d 100644 --- a/index.js +++ b/index.js @@ -1,28 +1,27 @@ var util = require('util'); var redis = require('redis'); +var _ = require('lodash'); var RedisNS = function(namespace, redisClient) { var self = this; - + _.extend(self, redisClient); self.namespace = namespace; self.redisClient = redisClient; - // "inherit" missing functions from redisClient - for(var i in redisClient) { - if(typeof self[i] !== 'function') { - self[i] = redisClient[i]; - } - } // Take care of pub/sub messages - redisClient.emit = function(eventType) { - if(eventType === 'message' && arguments.length === 3) { - arguments[1] = arguments[1].replace(self.namespace+':', ''); - arguments[2] = JSON.parse(arguments[2]); + self.on = function(event, callback) { + if(event !== 'message'){ + return redisClient.on(event, callback); } - redis.RedisClient.prototype.emit.apply(self, arguments); - }; + redisClient.on('message', function(namespacedChannel, message){ + channel = namespacedChannel.replace(self.namespace+':', ''); + callback(channel, message); + }); + + }; + self['append'] = function() { arguments[0] = self.namespace + ':' + arguments[0]; return self.redisClient['append'].apply(self.redisClient, arguments); @@ -338,7 +337,7 @@ var RedisNS = function(namespace, redisClient) { }; self['publish'] = function() { - arguments[0] = self.namespace + ':' + arguments[0]; + arguments[0] = self.namespace + ':' + arguments[0]; return self.redisClient['publish'].apply(self.redisClient, arguments); }; @@ -624,5 +623,4 @@ var RedisNS = function(namespace, redisClient) { }; }; -util.inherits(RedisNS, redis.RedisClient); module.exports = RedisNS; diff --git a/package.json b/package.json index e1aa8fd..e8e7675 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@octoblu/redis-ns", - "version": "1.1.2", + "version": "1.2.0", "description": "This module enables you to create Redis namespaces.", "keywords": [ "redis", @@ -16,6 +16,7 @@ } ], "dependencies": { + "lodash": "^4.0.0", "redis": "^2.4.2" }, "repository": { From 3b979ecfcb7629928739a54747d359136c703a25 Mon Sep 17 00:00:00 2001 From: Sqrt of Saturn Date: Mon, 21 Mar 2016 16:10:13 -0700 Subject: [PATCH 11/14] v1.2.1 use ioredis, which seems to break less. Or maybe it'll break everything we use. Who knows? --- index.js | 4 ++-- package.json | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index b97218d..a3816a4 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ var util = require('util'); -var redis = require('redis'); +var redis = require('ioredis'); var _ = require('lodash'); var RedisNS = function(namespace, redisClient) { @@ -21,7 +21,7 @@ var RedisNS = function(namespace, redisClient) { }); }; - + self['append'] = function() { arguments[0] = self.namespace + ':' + arguments[0]; return self.redisClient['append'].apply(self.redisClient, arguments); diff --git a/package.json b/package.json index e8e7675..81f8da7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@octoblu/redis-ns", - "version": "1.2.0", + "version": "1.2.1", "description": "This module enables you to create Redis namespaces.", "keywords": [ "redis", @@ -16,8 +16,8 @@ } ], "dependencies": { - "lodash": "^4.0.0", - "redis": "^2.4.2" + "ioredis": "^1.15.1", + "lodash": "^4.0.0" }, "repository": { "type": "git", From 75bdfeca18bdd4de6b6169aedb48dd61fb913e99 Mon Sep 17 00:00:00 2001 From: Roy van de Water Date: Wed, 23 Mar 2016 10:24:43 -0700 Subject: [PATCH 12/14] v1.2.2 Fix subscribe prefixing callbacks with namespace. (Really) --- index.js | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index a3816a4..6328f00 100644 --- a/index.js +++ b/index.js @@ -491,6 +491,12 @@ var RedisNS = function(namespace, redisClient) { self['subscribe'] = function() { for(var i=0 ; i < arguments.length ; i++) { + var isLastArgument = (i == arguments.length - 1); + var isCallback = _.isFunction(arguments[i]); + + if (isLastArgument && isCallback) { + break; + } arguments[i] = self.namespace + ':' + arguments[i]; } return self.redisClient['subscribe'].apply(self.redisClient, arguments); diff --git a/package.json b/package.json index 81f8da7..f56e9d8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@octoblu/redis-ns", - "version": "1.2.1", + "version": "1.2.2", "description": "This module enables you to create Redis namespaces.", "keywords": [ "redis", From d13e688625b8c9284ccd5b4d69c346c44908a10b Mon Sep 17 00:00:00 2001 From: sqrtofsaturn Date: Thu, 26 May 2016 12:19:44 -0700 Subject: [PATCH 13/14] v1.3.0 don't extend, instead wrap functions --- index.js | 6 +++++- package.json | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 6328f00..a767e64 100644 --- a/index.js +++ b/index.js @@ -4,10 +4,14 @@ var _ = require('lodash'); var RedisNS = function(namespace, redisClient) { var self = this; - _.extend(self, redisClient); self.namespace = namespace; self.redisClient = redisClient; + _.each( _.functionsIn(redisClient), function (key) { + self[key] = function() { + return self.redisClient[key].apply(self.redisClient, arguments); + } + }); // Take care of pub/sub messages self.on = function(event, callback) { diff --git a/package.json b/package.json index f56e9d8..89f02f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@octoblu/redis-ns", - "version": "1.2.2", + "version": "1.3.0", "description": "This module enables you to create Redis namespaces.", "keywords": [ "redis", @@ -46,4 +46,4 @@ "scripts": { "test": "istanbul cover _mocha -- -R spec --require coffee-coverage/register-istanbul" } -} \ No newline at end of file +} From 6f573e5558798e8038a37c9da4b55e31087cac4f Mon Sep 17 00:00:00 2001 From: sqrtofsaturn Date: Fri, 27 May 2016 16:59:34 -0700 Subject: [PATCH 14/14] v1.3.1 remove ioredis dep --- index.js | 1 - package.json | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/index.js b/index.js index a767e64..3f8da5b 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,4 @@ var util = require('util'); -var redis = require('ioredis'); var _ = require('lodash'); var RedisNS = function(namespace, redisClient) { diff --git a/package.json b/package.json index 89f02f1..51ed0d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@octoblu/redis-ns", - "version": "1.3.0", + "version": "1.3.1", "description": "This module enables you to create Redis namespaces.", "keywords": [ "redis", @@ -16,7 +16,6 @@ } ], "dependencies": { - "ioredis": "^1.15.1", "lodash": "^4.0.0" }, "repository": {