Skip to content

Support attributes (how?) #3

@Harrison88

Description

@Harrison88

The RESP3 spec allows attributes to be set on an object to convey auxiliary information about that object.

https://github.com/antirez/RESP3/blob/master/spec.md#attribute-type

The big question is in how this ought to be returned by the protocol reader. For example, suppose we get a mapping that looks like this dict:

{
    "foo": "bar" <- attribute on "bar"
}

Then how do we associate the attribute to the string "bar"? Ideally, attributes should be easily ignored by those who don't need them, but easy to work with by those who do.

Brainstormed solutions:

  1. Subclass everything so that an "attributes" attribute can be added to the objects. Doesn't seem ideal. I'd rather return the builtins than "RedisStr", etc., everywhere.
  2. Just insert the attributes where they are. Use a subclass of dict to distinguish it from a regular mapping. This might work when the attribute is already part of a collection already, but what if it's added to a response that's just an int or a str? We could just return it in a tuple like (attributes, object), but that would require adding type checks to check when an attribute was returned. Plus, it violates the ideal that attributes should be easily ignored.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions