Search code examples
databaseredisredis-cluster

Redis list with Binary array values instead of strings?


When I have look at the Redis documentation, I learn that we can use lists for strings (https://redis.io/docs/data-types/lists/).

However, for my use case it would be advantageous, if I could have a list with binary array values stored instead.

I have a few questions regarding that:

  • Is such a thing possible?
  • If not, is there a workaround?
  • Also, say the different binary arrays have size x, does that restrict the number of elements that can be stored in the list if the size x increases?

Solution

  • I would suggest against that setup, if possible. Instead, I would:

    • put each (possibly large) binary into its own key, through the SET command, naming each key with a hash of the binary data (for example, file:<CRC32 hash value>);
    • use a list to store just the aforementioned hashes (or the key names).

    Key values have a limit of 512MB; lists can have up to 2^32-1 items.