Skip to content

Find better ways to handle list values. #2

Description

@thorwhalen

At this point, in it's current raw form, the close-to-the-metal RedisBytesPersister can't write lists (or any iterable) at all.

The RedisPersister takes care of wrapping the base on to allow iterables other than string and bytes to be written. It looks like this:

    def __getitem__(self, k):
        val_type = self._source.type(k)
        if val_type == b"string":
            return self._source.get(k)
        elif val_type == b"list":
            return RedisList(self._source, k)

and uses a redisdol class called RedisList to wrap iterables.

But it's not ideal. Still, when you ask for your iterable back, you get a list of bytes. To remedy to that, we made the RedisStoreWithNumericLists
convenience class that will convert any bytes that can be converted to ints or floats. Still, not ideal because

  • we don't conserve the iterable type (we get lists, even if they were sets or tuples, etc.)
  • it's slow (we need to try to convert each element of the list
  • it's not complete (still, when list elements are strings, we get them back as bytes)

There must be some way to tell redis to remember some type information when writing stuff, so that we can use it to recover our original types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions