C:\Users\weibl\git\Enide-nodeclipse-1\org.nodeclipse.help\contents\.node_redis.md.html

# Redis

Redis is an open-source, networked, in-memory, key-value data store with optional durability.

Redis as Node.js also runs single-threaded.

Some helpful commands:

- `SET key` and `GET key`
- `KEYS *` list all keys. Not for production environment.
- `EXISTS key`

### redis-cli

redis-cli doesn't allow to execte scripts only commands.

        C:\Program Files\Redis>redis-cli.exe -h
        redis-cli 2.4.6 (git:26cdd13a)

        Usage: redis-cli [OPTIONS] [cmd [arg [arg ...]]]
          -h <hostname>    Server hostname (default: 127.0.0.1)
          -p <port>        Server port (default: 6379)
          -s <socket>      Server socket (overrides hostname and port)
          -a <password>    Password to use when connecting to the server
          -r <repeat>      Execute specified command N times
          -i <interval>    When -r is used, waits <interval> seconds per command.
                           It is possible to specify sub-second times like -i 0.1.
          -n <db>          Database number
          -x               Read last argument from STDIN
          -d <delimiter>   Multi-bulk delimiter in for raw formatting (default: \n)
          --raw            Use raw formatting for replies (default when STDOUT is not a tty)
          --latency        Enter a special mode continuously sampling latency.
          --help           Output this help and exit
          --version        Output version and exit

        Examples:
          cat /etc/passwd | redis-cli -x set mypasswd
          redis-cli get mypasswd
          redis-cli -r 100 lpush mylist x
          redis-cli -r 100 -i 1 info | grep used_memory_human:

        When no command is given, redis-cli starts in interactive mode.
        Type "help" in interactive mode for information on available commands.

### node_redis

node_redis is a node.js redis client.

Create new Node.js project, then run `npm install redis --save` in Terminal.

Hint: drap&drop `redis-cli` executable into Eclipse project to create comfortable link (see above).

Example

        var redis = require("redis"),
            client = redis.createClient();

        // if you'd like to select database 3, instead of 0 (default), call
        // client.select(3, function() { /* ... */ });

        client.on("error", function (err) {
            console.log("Error " + err);
        });

        client.set("string key", "string val", redis.print);
        client.hset("hash key", "hashtest 1", "some value", redis.print);
        client.hset(["hash key", "hashtest 2", "some other value"], redis.print);
        client.hkeys("hash key", function (err, replies) {
            console.log(replies.length + " replies:");
            replies.forEach(function (reply, i) {
                console.log("    " + i + ": " + reply);
            });
            client.quit();
        });

### Contribute

Edit online on GitHub