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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/node:7.10

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/mongo:3.4.4

working_directory: ~/repo

steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: npm install

- run: sudo apt-get update

- run: sudo apt-get install redis-server

- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

# run tests!
- run: npm run tests
12 changes: 12 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "airbnb",
"rules": {
"comma-dangle": ["error", {
"arrays": "never",
"objects": "never",
"imports": "never",
"exports": "never",
"functions": "never"
}]
}
}
29 changes: 23 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
redis-shard
===========
redis-shard-optimized
=====================

A consistent sharding library for redis in node
[![CircleCI](https://circleci.com/gh/ppsreejith/node-redis-shard.svg?style=svg)](https://circleci.com/gh/ppsreejith/node-redis-shard)

$ npm install redis-shard
A consistent sharding library for redis in node.

var RedisShard = require('redis-shard');
This project improves over the parent project by consistently distributing mget and mset over the sharded redis instances. (The parent implementation sends mget and mset to a single instance).

$ npm install redis-shard-optimized

var RedisShard = require('redis-shard-optimized');
var options = { servers: [ '127.0.0.1:6379', '127.0.0.1:6479' ], database : 1, password : 'redis4pulseLocker' };
var redis = new RedisShard(options);

// SINGLE
redis.set('foo', 'bar', console.log);
redis.get('foo', console.log);

// SINGLE (Multi key commands)
redis.mset(['key1', 'val1', 'key2', 'val2', 'key3', 'val3'], console.log);
redis.mget(['key1', 'key2', 'key3'], console.log);

// MULTI
var multi = redis.multi();
multi.set('foo', 'bar').set('bah', 'baz').expire('foo', 3600).expire('bah', 3600);
Expand All @@ -26,4 +34,13 @@ The constructor accepts an object containing the following options:
- `servers` (required) - An array of Redis servers (e.g. `'127.0.0.1:6379'`) to connect to
- `database` - Redis database to select
- `password` - Password for authentication
- `clientOptions` - Options object to be passed to each Redis client
- `clientOptions` - Options object to be passed to each Redis client

Tests
-----

To run tests, use

```
npm run tests
```
Loading