https://github.com/synodriver/sioresp
sans-io style redis protocol parser
https://github.com/synodriver/sioresp
redis redis-protocol resp resp3 sans-io
Last synced: about 2 months ago
JSON representation
sans-io style redis protocol parser
- Host: GitHub
- URL: https://github.com/synodriver/sioresp
- Owner: synodriver
- Created: 2022-03-09T15:20:14.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-18T06:25:36.000Z (about 3 years ago)
- Last Synced: 2025-02-14T00:23:52.944Z (4 months ago)
- Topics: redis, redis-protocol, resp, resp3, sans-io
- Language: Python
- Homepage:
- Size: 16.6 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
# sioresp
### sans-io style redis protocol parser for respv2 and v3
# usage
```python
from sioresp import Connection, Configc = 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
- [x] deserialize
- [x] serialize
- [x] unitest
- [ ] hiredis parser
- [ ] docs