Redis Implemented With Node

Nedis is a (partial) redis implementation written with node. Primarily for fun, however as our team grows larger, and as we add more non-technical team members over at LearnBoost I figured it would be nice help prevent the need for compiling development dependencies.

Nedis is an old side project I had going, and is no where near complete, but it does work, so I figured I would open-source it. Currently Nedis implements the unified Redis protocol which is an brilliantly simple binary-safe protocol that is human and machine friendly.

Using Existing Tools

Currently we use Redis for sessions in our app, so having a drop-in replacement is a great way to get session support for your app without booting up redis-server. For example the nodejs module connect-redis can utilize Matt Ranney’s fantastic redis client without change.

Another neat side-effect is that you can use existing redis tools such as redis-cli to interact with Nedis. First let’s start Nedis with nedis-server:

 $ nedis-server

Now we can play with the cli, interacting with node

 $ redis-cli 

 redis> hmset users:tj email tj@vision-media.ca age 23
 OK
 redis> hgetall users:tj
 1) "email"
 2) "tj@vision-media.ca"
 3) "age"
 4) "23"
 redis> keys users:*
 1) "users:tj"

Note that nedis-server basically consists of no more than the line of js below, so it’s easy to boot from within your process if desired.

 nedis.createServer(options).listen(port);

Supported Commands

Below is a list of the commands currently supported by Nedis

  • PING
  • ECHO
  • QUIT
  • SELECT
  • HLEN
  • HVALS
  • HKEYS
  • HSET
  • HMSET
  • HGET
  • HGETALL
  • HEXISTS
  • TYPE
  • EXISTS
  • RANDOMKEY
  • DEL
  • RENAME
  • KEYS
  • FLUSHDB
  • FLUSHALL
  • DBSIZE
  • INFO
  • BGREWRITEAOF
  • GET
  • GETSET
  • GET
  • SETNX
  • INCR
  • INCRBY
  • DECR
  • DECRBY
  • STRLEN
  • APPEND
  • SETRANGE
  • GETRANGE
  • MGET
  • MSET
  • MSETNX

    I have yet to do any kind of profiling, heavy optimization, or stress testing. If nothing more hopefully Nedis will help you guys explore Redis, or how you can prototype basic databases with node. Head over to the GitHub repo for installation instructions etc.