No description
Find a file
2021-10-08 20:38:51 +02:00
bench Parser improved, about 35% faster. Fixes for nested array like output of XINFO STREAM 2021-09-08 15:49:39 +07:00
src fix items iterrator yield wrong value 2021-09-19 07:29:39 +07:00
tests Stop expose internal values, add getters to improves runtime safety checks 2021-09-10 23:59:00 +07:00
.gitignore Initial commit 2018-09-01 18:08:54 +02:00
LICENSE Initial commit 2018-09-01 18:08:54 +02:00
README.md update README 2018-09-11 10:08:11 +02:00
redisparser.nimble Lets devs check value for nil themself to, avoid of repeat checks 2021-09-12 22:03:36 +07:00

nim-resp

RESP(REdis Serialization Protocol) Serialization for Nim

How to use

  echo $encodeValue(RedisValue(kind:vkStr, s:"Hello, World"))
  # # +Hello, World
  echo $encodeValue(RedisValue(kind:vkInt, i:341))
  # # :341
  echo $encodeValue(RedisValue(kind:vkError, err:"Not found"))
  # # -Not found
  echo $encodeValue(RedisValue(kind:vkArray, l: @[RedisValue(kind:vkStr, s:"Hello World"), RedisValue(kind:vkInt, i:23)]  ))
  # #*2
  # #+Hello World
  # #:23

  echo $encodeValue(RedisValue(kind:vkBulkStr, bs:"Hello, World THIS IS REALLY NICE"))
  # #$32
  # # Hello, World THIS IS REALLY NICE  
  echo decodeString("*3\r\n:1\r\n:2\r\n:3\r\n\r\n")
  # # @[1, 2, 3]
  echo decodeString("+Hello, World\r\n")
  # # Hello, World
  echo decodeString("-Not found\r\n")
  # # Not found
  echo decodeString(":1512\r\n")
  # # 1512
  echo $decodeString("$32\r\nHello, World THIS IS REALLY NICE\r\n")
  # Hello, World THIS IS REALLY NICE
  echo decodeString("*2\r\n+Hello World\r\n:23\r\n")
  # @[Hello World, 23]
  echo decodeString("*2\r\n*3\r\n:1\r\n:2\r\n:3\r\n\r\n*5\r\n:5\r\n:7\r\n+Hello Word\r\n-Err\r\n$6\r\nfoobar\r\n")
  # @[@[1, 2, 3], @[5, 7, Hello Word, Err, foobar]]
  echo $decodeString("*4\r\n:51231\r\n$3\r\nfoo\r\n$-1\r\n$3\r\nbar\r\n")
  # @[51231, foo, , bar]

Roadmap

  • Protocol serializer/deserializer
  • Tests