Last active
December 3, 2024 15:22
-
-
Save vndee/24d5c9b85e21509c06ddb6d94ca66392 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RESPObject: | |
""" | |
Base class for RESP data types. | |
Each RESP object maintains both its logical value and metadata about its | |
wire format representation, enabling efficient parsing and serialization. | |
""" | |
type: RESPObjectType | |
value: Any | |
bytes_length: int # Length of actual data in bytes | |
serialized_bytes_length: int # Length including protocol overhead (\r\n etc.) | |
class RESPSimpleString(RESPObject): | |
def __init__(self, value: str): | |
self.type = RESPObjectType.SIMPLE_STRING | |
self.value = value | |
class RESPBulkString(RESPObject): | |
def __init__(self, value: Optional[str], bytes_length: Optional[int] = None): | |
self.type = RESPObjectType.BULK_STRING | |
self.value = value | |
self.bytes_length = bytes_length |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment