Using Redis, quite familiar. Now, I am facing a situation where the normal PUBSUB mechanism won't really be a great way to handle certain situations.
Take a hash where we say store a reference to another hash using say HSET.
HSET "davids.trips" "trip1" "Stockholm"
HSET "davids.trips" "trip2" "London"
HSET "david" "age" "12"
HSET "david" "trips" "davids.trips" # Reference to the previous hash
Now, the last one internally is known and handled as reference hash.
However, the problem we are facing now, is when expire now occurs on map "david"
we would like the ability to invalidate the davids.trips
as well so it does not linger along.
Now, we can pubsub to expire on HSET "david" say, but if our server is down then we won't be able to pick it up and it will be lost on us.
Doing this from Java and we run into the possibility of missing the expire pubsub message.
Instead, if we where to receive the message over a stream
instead, the message would have to be consumed by at least one and we could ensure it is cleared.
Now, how can we do that?
Can we convert pubsub messages to stream like behaviour easily?
If so, how? I am using Jedis but I can send some code to potentially do this. Ideally, the conversion would happen within Redis server so that pubsub messages are never not transformed into Streams.
Btw on : https://redis.io/topics/pubsub we can find: "Please note that redis-cli will not accept any commands once in subscribed mode and can only quit the mode with Ctrl-C." So the problem is that it becomes blocking if we were to subscribe within Redis and then try to consume and turn them into streams.
There has to be a way to create a thread using lua and pubsub there?