Let me try to understand this.
You have cache key Y with tags A, B, C. You perform the following operations:
SADD tags:A Y
SADD tags:B Y
SADD tags:C Y
SET key:Y ...
The second part of your explanation suggests that you are also performing:
SADD ktags:Y A
SADD ktags:Y B
SADD ktags:Y C
Then to clear your data, you perform a SUNION across ktags:* entries
based on the output of SMEMBERS tags:X .
> In a perfect world, would it be possible to use LUA scripting to send
> a single EVAL to redis, that will both do the SUNION to get the
> invalidated keys, within a DEL command? EG (pseudo-code): EVAL {DEL
> (SUNION tagA tagB tagC...)}...
You could do that, but I wouldn't. If you end up needing to invalidate
more than a few thousand tags, or unioning more than a few keys, you
will cause Redis to pause for a surprisingly long time.
I've got an idea for an incremental clearing of this kind of data
(which would be faster scripted), which you can do for some user-set
number of keys per pass, which wouldn't cause Redis to pause doing too
much work. You could call it from a worker every few seconds (or more
often, depending on how quickly you want to clear out old data), but
it wouldn't work quite right in scripted cluster (but would work fine
in regular Redis scripting).
> And, within the context of redis cluster (http://redis.io/topics/
> cluster-spec), it is said that "Redis Cluster implements all the
> single keys commands available in the non distributed version of
> Redis. Commands performing complex multi key operations like Set type
> unions or intersections are not implemented, and in general all the
> operations where in theory keys are not available in the same node are
> not implemented."
>
> So, based on the above quote from the redis cluster spec, if a
> scripting EVAL was issued by a client (EG: phpredis) to the redis
> cluster, what would happen? Would the node within redis cluster be
> able to then broadcast the SUNION to all the potential nodes in the
> cluster and then aggregate the results and then perform the multi-key
> DEL (once again broadcasting to all the hashed nodes in the cluster)?
> Or would that be impossible and every set have to be retrieved
> separately (that would seem to be very inefficient)?
No. Redis specifically does not broadcast commands anywhere. Your
desire to union keys would not work.
Regards,
- Josiah
- Josiah
> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To post to this group, send email to redi...@googlegroups.com.
> To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
>
>
Hey guys, we just wrote a blog post about how we are doing Redis caching with tags. Check it out and maybe it could help some of you. We used some Lua scripting.