Skip to content

synodriver/sioresp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

sioresp

sans-io style redis protocol parser for respv2 and v3

usage

from sioresp import Connection, Config

c = Connection(Config(resp_version=3))
c.feed_data(b"+OK\r\n")
data = next(c)  # b"OK"
assert data == b"OK"
try:
    next(c)  # raise StopIteration
except Exception as e:
    assert type(e) == StopIteration
c.feed_data(b"~5\r\n+orange\r\n+apple\r\n#t\r\n:100\r\n:999\r\n")
data = next(c)
assert data == {True, 100, 999, b'apple', b'orange'}

data = c.send_command("GET", "key")
assert data == b'*2\r\n$3\r\nGET\r\n$3\r\nkey\r\n'

Note:

  • You can subclass Connection class to rewrite pack_element method to have customs serialize strategies.

TODO

  • deserialize
  • serialize
  • unitest
  • hiredis parser
  • docs

About

sans-io style redis protocol parser

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages