redisclient

Redis client for Nim

Pure Nim score 15/100 · tests present · no docs generated

Summary

Latest Version Unknown
License Apache2
CI Status Failing
Downloads 0
Last Indexed 2026-07-21 05:24

Installation

nimble install redisclient
choosenim install redisclient
git clone https://github.com/xmonader/nim-redisclient

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
redisclient - - - - - - -

Source

Repository https://github.com/xmonader/nim-redisclient
Homepage https://github.com/xmonader/nim-redisclient
Registry Source nimble_official

README

redisclient

Provides sync and async clients to communicate with redis servers using nim-redisparser

Executing commands

Sync

  let con = open("localhost", 6379.Port)
  echo $con.execCommand("PING", @[])
  echo $con.execCommand("SET", @["auser", "avalue"])
  echo $con.execCommand("GET", @["auser"])
  echo $con.execCommand("SCAN", @["0"])

Async

  let con = await openAsync("localhost", 6379.Port)
  echo await con.execCommand("PING", @[])
  echo await con.execCommand("SET", @["auser", "avalue"])
  echo await con.execCommand("GET", @["auser"])
  echo await con.execCommand("SCAN", @["0"])
  echo await con.execCommand("SET", @["auser", "avalue"])
  echo await con.execCommand("GET", @["auser"])
  echo await con.execCommand("SCAN", @["0"])

  await con.enqueueCommand("PING", @[])
  await con.enqueueCommand("PING", @[])
  await con.enqueueCommand("PING", @[])
  echo await con.commitCommands()

Pipelining

You can use enqueueCommand and commitCommands to make use of redis pipelining

  con.enqueueCommand("PING", @[])
  con.enqueueCommand("PING", @[])
  con.enqueueCommand("PING", @[])

  echo $con.commitCommands()

Connection Pool

There is a simple connection pool included - which was a folk of zedeus's redpool

import redisclient, redisclient/connpool
proc main {.async.} =
    let pool = await newAsyncRedisPool(1)
    let conn = await pool.acquire()
    echo await conn.ping()
    pool.release(conn)

    pool.withAcquire(conn2):
      echo await conn2.ping()
    await pool.close()
waitFor main()

Roadmap

  • [X] Pipelining
  • [X] Async APIs
  • [X] Friendlier API for builtin redis commands (adapted code from https://github.com/nim-lang/redis)