Home > redis-semantics

redis-semantics

Redis-semantics is a project mainly written in JAVASCRIPT and COFFEESCRIPT, it's free.

(impl) and (client/server tests) for each Redis command, with a derived mock client/server e.g. for your apps' tests

Status: early development

  • The .createClient client/server works and can be used to replace (Redis + the node_redis client) in your apps' tests
  • TODO: implement the rest of the commants
  • TODO: implement the (client/server-independent test)-runner

Commands implemented (but not yet tested!)

del, exists, getbit, getrange, getset, lindex, linsert, llen, lpop, lpush, lpushx, lrange, lrem, lset, ltrim, mget, mset, msetnx, randomkey, rename, renamenx, rpop, rpoplpush, rpush, rpushx, sadd, scard, sdiff, sdiffstore, setnx, sinter, strlen, type

(Implementation) and (client/server-independent tests) for each command

For example, here's src/commands/get.coffee

module.exports =

  get: (k) ->
    if @items[k]?
      @assertString @items[k]
    else
      null

  tests:
    eg: """
      set k, v: OK
      get k:    v
    """
    wrong_type: """
      non-string k: OK
      get k:        ERROR
    """

For details, see src/OVERVIEW.md

Application: running a mock client/server

This client-with-its-own-server can be useful for development/testing, and will be tested for full equivalence to mranney's node_redis.

var redis = require('redis-semantics');
var client = redis.createClient();
...
client.append(k, v, fuction(err, reply) {
    ...
})

Application: testing your client/server implementations

For example, to test node_redis + Redis 2.0:

    TODO

Application: generating awesome documentation for each command

    TODO

Developing

cd redis-semantics; npm link
cake build && cake test
Previous:MineKit