/goresp

Go implementation for RESP (REdis Serialization Protocol)

Primary LanguageGoApache License 2.0Apache-2.0

Build Status Coverage Status codebeat badge Go Report Card CII Best Practices FOSSA Status

goresp

Go implementation for RESP (REdis Serialization Protocol)

Documentation

For documentation see Godoc.

Data types

This table has examples for how data will be encoded and decoded.

RESP Representation Human-readable RESP Type Go Representation
"\r\n" (empty) undefined nil
":1\r\n" 1 Integer int64(1)
"+abc\r\n" "abc" Simple String "abc"
"+\r\n" "" Simple String ""
"-abc\r\n" "abc" Error error (msg=abc)
"-\r\n" "" Error error
"$5\r\nabc\r\n\r\n" "abc\r\n" Bulk String []byte{'a','b','c'}
"$0\r\n\r\n" "" Bulk String []byte{}
"*0\r\n" [] Array []interface{}{}
"*2\r\n$3\r\nfoo\r\n$3\r\nbar\r\n" ["foo", "bar"] Array []interface{}{[]byte{'f','o','o'}, []byte{'b','a','r'}}
"*2\r\n:1\r\n$3\r\nfoo\r\n" [6, "foobar"] Array (mixed) []interface{}{int64(1), []byte{'f', 'o', 'o'}}

Benchmarks

Benchmark name (1) (2) (3) (4)
BenchmarkReadSmallString 20000000 88.7 16 2
BenchmarkReadInteger 10000000 126 16 3
BenchmarkReadBulkString 20000000 107 16 3
BenchmarkReadArray 3000000 580 176 14
  • (1): Total Repetitions achieved in constant time, higher means more confident result
  • (2): Single Repetition Duration (ns/op), lower is better
  • (3): Heap Memory (B/op), lower is better
  • (4): Average Allocations per Repetition (allocs/op), lower is better

TODO List

[X] Change Simple string decoded type to string

License

Unless otherwise noted, All source files in this library are distributed under the Apache License 2.0 found in the LICENSE file.

FOSSA Status