# Module redis

This module implements a redis client. It allows you to connect to a redis-server instance, send commands and receive replies.

Beware: Most (if not all) functions that return a `TRedisString` may return `redisNil`, and functions which return a `TRedisList` may return `nil`.

# Imports

sockets, os, strutils, parseutils

# Types

    TRedis = object
      socket: TSocket
      connected: bool

    TRedisStatus = string

    TRedisInteger = BiggestInt

    TRedisString = string

  Bulk reply

    TRedisList = seq[TRedisString]

  Multi-bulk reply

    EInvalidReply = object of ESynch

  Invalid reply from redis

    ERedis = object of ESynch

  Error in redis

# Consts

    redisNil = "\0\0"

# Procs

    proc open(host = "localhost"; port = 6379.TPort): TRedis {.raises: [EOS],
        tags: [FReadIO].}

  Opens a connection to the redis server.

    proc del(r: TRedis; keys: varargs[string]): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Delete a key or multiple keys

    proc exists(r: TRedis; key: string): bool {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Determine if a key exists

    proc expire(r: TRedis; key: string; seconds: int): bool {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Set a key's time to live in seconds. Returns false if the key could not be found or the timeout could not be set.

    proc expireAt(r: TRedis; key: string; timestamp: int): bool {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Set the expiration for a key as a UNIX timestamp. Returns false if the key could not be found or the timeout could not be set.

    proc keys(r: TRedis; pattern: string): TRedisList {.
        raises: [EOS, ETimeout, EInvalidReply, EInvalidValue, EOverflow, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Find all keys matching the given pattern

    proc move(r: TRedis; key: string; db: int): bool {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Move a key to another database. Returns true on a successful move.

    proc persist(r: TRedis; key: string): bool {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Remove the expiration from a key. Returns true when the timeout was removed.

    proc randomKey(r: TRedis): TRedisString {.
        raises: [EOS, ETimeout, EInvalidReply, ERedis, EInvalidValue, EOverflow],
        tags: [FWriteIO, FReadIO, FTime].}

  Return a random key from the keyspace

    proc rename(r: TRedis; key, newkey: string): TRedisStatus {.
        raises: [EOS, EInvalidReply, EInvalidValue, ETimeout, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Rename a key.

  WARNING: Overwrites newkey if it exists!

    proc renameNX(r: TRedis; key, newkey: string): bool {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Same as `rename` but doesn't continue if newkey exists. Returns true if key was renamed.

    proc ttl(r: TRedis; key: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Get the time to live for a key

    proc keyType(r: TRedis; key: string): TRedisStatus {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Determine the type stored at key

    proc append(r: TRedis; key, value: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Append a value to a key

    proc decr(r: TRedis; key: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Decrement the integer value of a key by one

    proc decrBy(r: TRedis; key: string; decrement: int): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Decrement the integer value of a key by the given number

    proc get(r: TRedis; key: string): TRedisString {.
        raises: [EOS, ETimeout, EInvalidReply, ERedis, EInvalidValue, EOverflow],
        tags: [FWriteIO, FReadIO, FTime].}

  Get the value of a key. Returns redisNil when key doesn't exist.

    proc getBit(r: TRedis; key: string; offset: int): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Returns the bit value at offset in the string value stored at key

    proc getRange(r: TRedis; key: string; start, stop: int): TRedisString {.
        raises: [EOS, ETimeout, EInvalidReply, ERedis, EInvalidValue, EOverflow],
        tags: [FWriteIO, FReadIO, FTime].}

  Get a substring of the string stored at a key

    proc getSet(r: TRedis; key: string; value: string): TRedisString {.
        raises: [EOS, ETimeout, EInvalidReply, ERedis, EInvalidValue, EOverflow],
        tags: [FWriteIO, FReadIO, FTime].}

  Set the string value of a key and return its old value. Returns redisNil when key doesn't exist.

    proc incr(r: TRedis; key: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Increment the integer value of a key by one.

    proc incrBy(r: TRedis; key: string; increment: int): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Increment the integer value of a key by the given number

    proc setk(r: TRedis; key, value: string) {.
        raises: [EOS, EInvalidReply, EInvalidValue, ETimeout, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Set the string value of a key.

  NOTE: This function had to be renamed due to a clash with the set type.

    proc setNX(r: TRedis; key, value: string): bool {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Set the value of a key, only if the key does not exist. Returns true if the key was set.

    proc setBit(r: TRedis; key: string; offset: int; value: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Sets or clears the bit at offset in the string value stored at key

    proc setEx(r: TRedis; key: string; seconds: int; value: string): TRedisStatus {.
        raises: [EOS, EInvalidReply, EInvalidValue, ETimeout, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Set the value and expiration of a key

    proc setRange(r: TRedis; key: string; offset: int; value: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Overwrite part of a string at key starting at the specified offset

    proc strlen(r: TRedis; key: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Get the length of the value stored in a key. Returns 0 when key doesn't exist.

    proc hDel(r: TRedis; key, field: string): bool {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Delete a hash field at key. Returns true if the field was removed.

    proc hExists(r: TRedis; key, field: string): bool {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Determine if a hash field exists.

    proc hGet(r: TRedis; key, field: string): TRedisString {.
        raises: [EOS, ETimeout, EInvalidReply, ERedis, EInvalidValue, EOverflow],
        tags: [FWriteIO, FReadIO, FTime].}

  Get the value of a hash field

    proc hGetAll(r: TRedis; key: string): TRedisList {.
        raises: [EOS, ETimeout, EInvalidReply, EInvalidValue, EOverflow, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Get all the fields and values in a hash

    proc hIncrBy(r: TRedis; key, field: string; incr: int): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Increment the integer value of a hash field by the given number

    proc hKeys(r: TRedis; key: string): TRedisList {.
        raises: [EOS, ETimeout, EInvalidReply, EInvalidValue, EOverflow, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Get all the fields in a hash

    proc hLen(r: TRedis; key: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Get the number of fields in a hash

    proc hMGet(r: TRedis; key: string; fields: varargs[string]): TRedisList {.
        raises: [EOS, ETimeout, EInvalidReply, EInvalidValue, EOverflow, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Get the values of all the given hash fields

    proc hMSet(r: TRedis; key: string;
               fieldValues: openarray[tuple[field, value: string]]) {.
        raises: [EOS, EInvalidReply, EInvalidValue, ETimeout, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Set multiple hash fields to multiple values

    proc hSet(r: TRedis; key, field, value: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Set the string value of a hash field

    proc hSetNX(r: TRedis; key, field, value: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Set the value of a hash field, only if the field does not exist

    proc hVals(r: TRedis; key: string): TRedisList {.
        raises: [EOS, ETimeout, EInvalidReply, EInvalidValue, EOverflow, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Get all the values in a hash

    proc bLPop(r: TRedis; keys: varargs[string]; timeout: int): TRedisList {.
        raises: [EOS, ETimeout, EInvalidReply, EInvalidValue, EOverflow, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Remove and get the first element in a list, or block until one is available

    proc bRPop(r: TRedis; keys: varargs[string]; timeout: int): TRedisList {.
        raises: [EOS, ETimeout, EInvalidReply, EInvalidValue, EOverflow, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Remove and get the last element in a list, or block until one is available.

    proc bRPopLPush(r: TRedis; source, destination: string; timeout: int): TRedisString {.
        raises: [EOS, ETimeout, EInvalidReply, ERedis, EInvalidValue, EOverflow],
        tags: [FWriteIO, FReadIO, FTime].}

  Pop a value from a list, push it to another list and return it; or block until one is available.

  http://redis.io/commands/brpoplpush

    proc lIndex(r: TRedis; key: string; index: int): TRedisString {.
        raises: [EOS, ETimeout, EInvalidReply, ERedis, EInvalidValue, EOverflow],
        tags: [FWriteIO, FReadIO, FTime].}

  Get an element from a list by its index

    proc lInsert(r: TRedis; key: string; before: bool; pivot, value: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Insert an element before or after another element in a list

    proc lLen(r: TRedis; key: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Get the length of a list

    proc lPop(r: TRedis; key: string): TRedisString {.
        raises: [EOS, ETimeout, EInvalidReply, ERedis, EInvalidValue, EOverflow],
        tags: [FWriteIO, FReadIO, FTime].}

  Remove and get the first element in a list

    proc lPush(r: TRedis; key, value: string; create: bool = True): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Prepend a value to a list. Returns the length of the list after the push. The `create` param specifies whether a list should be created if it doesn't exist at `key`. More specifically if `create` is True, LPUSH will be used, otherwise LPUSHX.

    proc lRange(r: TRedis; key: string; start, stop: int): TRedisList {.
        raises: [EOS, ETimeout, EInvalidReply, EInvalidValue, EOverflow, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Get a range of elements from a list. Returns nil when key doesn't exist.

    proc lRem(r: TRedis; key: string; value: string; count: int = 0): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Remove elements from a list. Returns the number of elements that have been removed.

    proc lSet(r: TRedis; key: string; index: int; value: string) {.
        raises: [EOS, EInvalidReply, EInvalidValue, ETimeout, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Set the value of an element in a list by its index

    proc lTrim(r: TRedis; key: string; start, stop: int) {.
        raises: [EOS, EInvalidReply, EInvalidValue, ETimeout, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Trim a list to the specified range

    proc rPop(r: TRedis; key: string): TRedisString {.
        raises: [EOS, ETimeout, EInvalidReply, ERedis, EInvalidValue, EOverflow],
        tags: [FWriteIO, FReadIO, FTime].}

  Remove and get the last element in a list

    proc rPopLPush(r: TRedis; source, destination: string): TRedisString {.
        raises: [EOS, ETimeout, EInvalidReply, ERedis, EInvalidValue, EOverflow],
        tags: [FWriteIO, FReadIO, FTime].}

  Remove the last element in a list, append it to another list and return it

    proc rPush(r: TRedis; key, value: string; create: bool = True): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Append a value to a list. Returns the length of the list after the push. The `create` param specifies whether a list should be created if it doesn't exist at `key`. More specifically if `create` is True, RPUSH will be used, otherwise RPUSHX.

    proc sadd(r: TRedis; key: string; member: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Add a member to a set

    proc scard(r: TRedis; key: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Get the number of members in a set

    proc sdiff(r: TRedis; keys: varargs[string]): TRedisList {.
        raises: [EOS, ETimeout, EInvalidReply, EInvalidValue, EOverflow, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Subtract multiple sets

    proc sdiffstore(r: TRedis; destination: string; keys: varargs[string]): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Subtract multiple sets and store the resulting set in a key

    proc sinter(r: TRedis; keys: varargs[string]): TRedisList {.
        raises: [EOS, ETimeout, EInvalidReply, EInvalidValue, EOverflow, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Intersect multiple sets

    proc sinterstore(r: TRedis; destination: string; keys: varargs[string]): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Intersect multiple sets and store the resulting set in a key

    proc sismember(r: TRedis; key: string; member: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Determine if a given value is a member of a set

    proc smembers(r: TRedis; key: string): TRedisList {.
        raises: [EOS, ETimeout, EInvalidReply, EInvalidValue, EOverflow, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Get all the members in a set

    proc smove(r: TRedis; source: string; destination: string; member: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Move a member from one set to another

    proc spop(r: TRedis; key: string): TRedisString {.
        raises: [EOS, ETimeout, EInvalidReply, ERedis, EInvalidValue, EOverflow],
        tags: [FWriteIO, FReadIO, FTime].}

  Remove and return a random member from a set

    proc srandmember(r: TRedis; key: string): TRedisString {.
        raises: [EOS, ETimeout, EInvalidReply, ERedis, EInvalidValue, EOverflow],
        tags: [FWriteIO, FReadIO, FTime].}

  Get a random member from a set

    proc srem(r: TRedis; key: string; member: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Remove a member from a set

    proc sunion(r: TRedis; keys: varargs[string]): TRedisList {.
        raises: [EOS, ETimeout, EInvalidReply, EInvalidValue, EOverflow, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Add multiple sets

    proc sunionstore(r: TRedis; destination: string; key: varargs[string]): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Add multiple sets and store the resulting set in a key

    proc zadd(r: TRedis; key: string; score: int; member: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Add a member to a sorted set, or update its score if it already exists

    proc zcard(r: TRedis; key: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Get the number of members in a sorted set

    proc zcount(r: TRedis; key: string; min: string; max: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Count the members in a sorted set with scores within the given values

    proc zincrby(r: TRedis; key: string; increment: string; member: string): TRedisString {.
        raises: [EOS, ETimeout, EInvalidReply, ERedis, EInvalidValue, EOverflow],
        tags: [FWriteIO, FReadIO, FTime].}

  Increment the score of a member in a sorted set

    proc zinterstore(r: TRedis; destination: string; numkeys: string;
                     keys: openarray[string]; weights: openarray[string] = [];
                     aggregate: string = ""): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Intersect multiple sorted sets and store the resulting sorted set in a new key

    proc zrange(r: TRedis; key: string; start: string; stop: string;
                withScores: bool): TRedisList {.
        raises: [EOS, ETimeout, EInvalidReply, EInvalidValue, EOverflow, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Return a range of members in a sorted set, by index

    proc zrangebyscore(r: TRedis; key: string; min: string; max: string;
                       withScore: bool = false; limit: bool = False;
                       limitOffset: int = 0; limitCount: int = 0): TRedisList {.
        raises: [EOS, ETimeout, EInvalidReply, EInvalidValue, EOverflow, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Return a range of members in a sorted set, by score

    proc zrank(r: TRedis; key: string; member: string): TRedisString {.
        raises: [EOS, ETimeout, EInvalidReply, ERedis, EInvalidValue, EOverflow],
        tags: [FWriteIO, FReadIO, FTime].}

  Determine the index of a member in a sorted set

    proc zrem(r: TRedis; key: string; member: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Remove a member from a sorted set

    proc zremrangebyrank(r: TRedis; key: string; start: string; stop: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Remove all members in a sorted set within the given indexes

    proc zremrangebyscore(r: TRedis; key: string; min: string; max: string): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Remove all members in a sorted set within the given scores

    proc zrevrange(r: TRedis; key: string; start: string; stop: string;
                   withScore: bool): TRedisList {.
        raises: [EOS, ETimeout, EInvalidReply, EInvalidValue, EOverflow, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Return a range of members in a sorted set, by index, with scores ordered from high to low

    proc zrevrangebyscore(r: TRedis; key: string; min: string; max: string;
                          withScore: bool = false; limit: bool = False;
                          limitOffset: int = 0; limitCount: int = 0): TRedisList {.
        raises: [EOS, ETimeout, EInvalidReply, EInvalidValue, EOverflow, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Return a range of members in a sorted set, by score, with scores ordered from high to low

    proc zrevrank(r: TRedis; key: string; member: string): TRedisString {.
        raises: [EOS, ETimeout, EInvalidReply, ERedis, EInvalidValue, EOverflow],
        tags: [FWriteIO, FReadIO, FTime].}

  Determine the index of a member in a sorted set, with scores ordered from high to low

    proc zscore(r: TRedis; key: string; member: string): TRedisString {.
        raises: [EOS, ETimeout, EInvalidReply, ERedis, EInvalidValue, EOverflow],
        tags: [FWriteIO, FReadIO, FTime].}

  Get the score associated with the given member in a sorted set

    proc zunionstore(r: TRedis; destination: string; numkeys: string;
                     keys: openarray[string]; weights: openarray[string] = [];
                     aggregate: string = ""): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Add multiple sorted sets and store the resulting sorted set in a new key

    proc discardMulti(r: TRedis) {.raises: [EOS, EInvalidReply, EInvalidValue,
                                            ETimeout, ERedis],
                                   tags: [FWriteIO, FReadIO, FTime].}

  Discard all commands issued after MULTI

    proc exec(r: TRedis): TRedisList {.raises: [EOS, ETimeout, EInvalidReply,
        EInvalidValue, EOverflow, ERedis], tags: [FWriteIO, FReadIO, FTime].}

  Execute all commands issued after MULTI

    proc multi(r: TRedis) {.raises: [EOS, EInvalidReply, EInvalidValue, ETimeout,
                                     ERedis], tags: [FWriteIO, FReadIO, FTime].}

  Mark the start of a transaction block

    proc unwatch(r: TRedis) {.raises: [EOS, EInvalidReply, EInvalidValue, ETimeout,
                                       ERedis], tags: [FWriteIO, FReadIO, FTime].}

  Forget about all watched keys

    proc watch(r: TRedis; key: varargs[string]) {.
        raises: [EOS, EInvalidReply, EInvalidValue, ETimeout, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Watch the given keys to determine execution of the MULTI/EXEC block

    proc auth(r: TRedis; password: string) {.
        raises: [EOS, EInvalidReply, EInvalidValue, ETimeout, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Authenticate to the server

    proc echoServ(r: TRedis; message: string): TRedisString {.
        raises: [EOS, ETimeout, EInvalidReply, ERedis, EInvalidValue, EOverflow],
        tags: [FWriteIO, FReadIO, FTime].}

  Echo the given string

    proc ping(r: TRedis): TRedisStatus {.raises: [EOS, ETimeout, ERedis,
        EInvalidReply, EInvalidValue], tags: [FWriteIO, FReadIO, FTime].}

  Ping the server

    proc quit(r: TRedis) {.raises: [EOS, EInvalidReply, EInvalidValue, ETimeout,
                                    ERedis], tags: [FWriteIO, FReadIO, FTime].}

  Close the connection

    proc select(r: TRedis; index: int): TRedisStatus {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Change the selected database for the current connection

    proc bgrewriteaof(r: TRedis) {.raises: [EOS, EInvalidReply, EInvalidValue,
                                            ETimeout, ERedis],
                                   tags: [FWriteIO, FReadIO, FTime].}

  Asynchronously rewrite the append-only file

    proc bgsave(r: TRedis) {.raises: [EOS, EInvalidReply, EInvalidValue, ETimeout,
                                      ERedis], tags: [FWriteIO, FReadIO, FTime].}

  Asynchronously save the dataset to disk

    proc configGet(r: TRedis; parameter: string): TRedisList {.
        raises: [EOS, ETimeout, EInvalidReply, EInvalidValue, EOverflow, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Get the value of a configuration parameter

    proc configSet(r: TRedis; parameter: string; value: string) {.
        raises: [EOS, EInvalidReply, EInvalidValue, ETimeout, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Set a configuration parameter to the given value

    proc configResetStat(r: TRedis) {.raises: [EOS, EInvalidReply, EInvalidValue,
        ETimeout, ERedis], tags: [FWriteIO, FReadIO, FTime].}

  Reset the stats returned by INFO

    proc dbsize(r: TRedis): TRedisInteger {.raises: [EOS, ETimeout, ERedis,
        EInvalidReply, EInvalidValue], tags: [FWriteIO, FReadIO, FTime].}

  Return the number of keys in the selected database

    proc debugObject(r: TRedis; key: string): TRedisStatus {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Get debugging information about a key

    proc debugSegfault(r: TRedis) {.raises: [EOS], tags: [FWriteIO].}

  Make the server crash

    proc flushall(r: TRedis): TRedisStatus {.
        raises: [EOS, EInvalidReply, EInvalidValue, ETimeout, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Remove all keys from all databases

    proc flushdb(r: TRedis): TRedisStatus {.raises: [EOS, EInvalidReply,
        EInvalidValue, ETimeout, ERedis], tags: [FWriteIO, FReadIO, FTime].}

  Remove all keys from the current database

    proc info(r: TRedis): TRedisString {.raises: [EOS, ETimeout, EInvalidReply,
        ERedis, EInvalidValue, EOverflow], tags: [FWriteIO, FReadIO, FTime].}

  Get information and statistics about the server

    proc lastsave(r: TRedis): TRedisInteger {.
        raises: [EOS, ETimeout, ERedis, EInvalidReply, EInvalidValue],
        tags: [FWriteIO, FReadIO, FTime].}

  Get the UNIX time stamp of the last successful save to disk

    proc save(r: TRedis) {.raises: [EOS, EInvalidReply, EInvalidValue, ETimeout,
                                    ERedis], tags: [FWriteIO, FReadIO, FTime].}

  Synchronously save the dataset to disk

    proc shutdown(r: TRedis) {.raises: [EOS, ETimeout, ERedis],
                               tags: [FWriteIO, FReadIO, FTime].}

  Synchronously save the dataset to disk and then shut down the server

    proc slaveof(r: TRedis; host: string; port: string) {.
        raises: [EOS, EInvalidReply, EInvalidValue, ETimeout, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Make the server a slave of another instance, or promote it as master

# Iterators

    iterator hPairs(r: TRedis; key: string): tuple[key, value: string] {.
        raises: [EOS, ETimeout, EInvalidReply, EInvalidValue, EOverflow, ERedis],
        tags: [FWriteIO, FReadIO, FTime].}

  Iterator for keys and values in a hash.

Generated: 2013-05-21 09:55:19 UTC