strategy for storing and invalidating data based on one or more attributes

12 views
Skip to first unread message

Doug Davis

unread,
Jun 19, 2017, 1:27:21 PM6/19/17
to Redis DB
Hello,

I am going to be storing many objects (really more like serialized associative arrays)  in Redis.

I want a way to easily remove/invalidate data that has certain attributes.

To make up an oversimplified example, let's say we have class rosters stored that I identify with attributes such as:
institution=B
year=2017
term=Fall
offering id=2939 (like the primary key)


But, I want to be able to invalidate all rosters based on any attributes I choose.  For example:
For examples, I may want to remove data from redis:
Remove where institution=B
Remove where offering id=2939
Remove Where Institution=A and Year=2017 and term=Spring

Would the best way to set that up be having a key in Redis to use just for invalidation purposes?

For example the key for the above would be:
(institution=B)(offering id=2939)(term=Fall)(year=2017)

attributes would be in alphabetical order

And the value would be
offering id=2939

It would just be a pointer to the key for the actual data in Redis.  The key for the actual data would be offering id=2939.

Then I can just look for
*(institution=B)*(year=2017)*

To just search on two attributes.  Is this reasonable?  Or is there a more simple solution?

Thanks,
Doug

Itamar Haber

unread,
Jun 19, 2017, 5:38:09 PM6/19/17
to Redis DB
I believe you can find most of the questions to your answers at https://redis.io/topics/indexes - I recommend that you begin by reading that and if you have any further questions, always feel free to return and ask. Tersely, scanning the keyspace for keyname patterns is slow and inefficient - you should index your attributes, e.g. by using Sets, to retrieve the relevant data.

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+unsubscribe@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.



Reply all
Reply to author
Forward
0 new messages