So I primarily make use of Redis sets for a lot of use cases. Where I primarily sort of want to maintain the elements. But as Redis does not allow to store empty sets it becomes tricky.
There are a few ways to do circumvent this from the application, for example: You could build an index of keys that shows that a redis set has values (or ready for use). Prior to getting the values, you’d have to check from this index first.
Another way is to create a dummy value that your application would ignore during loading, for example inserting a empty string “” as the first object.
It sounds like the best approach is to just add another layer in to track your keys. Anytime you add a key-value, add the key to your used key data structure. If the key exists here, then (empty list or set) is a legit value. If the key doesn’t exist here, then the (empty list or set) return is really undefined. I’m probably missing something, but that seems like the best approach without odd hacks to get around a foundational aspect of redis.