4 ms·
Hmm. The author's recommendation to use Redis' 'KEYS' command to pattern match keys for invalidation is a dangerous one. 'KEYS' runs in O(n) time. If you're usi
by tabbyjabby 15y ago
Hmm. The author's recommendation to use Redis' 'KEYS' command to pattern match keys for invalidation is a dangerous one. 'KEYS' runs in O(n) time. If you're using Redis in a serious production environment, you do not want want to be using an O(n) command each time you need to invalidate a group of keys. It's better to group related items in a Redis hash table, and that way they are all stored under one common key.
Honestly, I think this article is a more impoverished version of antirez's post on the same topic [1]. antirez, being one of the principal authors of Redis, is a much more authoritative source, and he actually describes all the patterns that this author described in greater detail.
[1] http://antirez.com/post/take-advantage-of-redis-adding-it-to-your-stack.html http://antirez.com/post/take-advantage-of-redis-adding-it-to...
- LeafStorm 15y agoAnd the O(N) is against your entire keyset, and not just the keys you're erasing. Which makes it even worse.
- dickeytk 15y agoThanks for linking the antirez article, I actually haven't seen that one before I wrote the article. I put a link to it in the article. As far as they keys thing, it's obviously been a major point of contention with my article. I know the warning, I just don't think it's actually a problem for cache invalidation. See below on another comment of someone having similar concerns for my explanation why.
- dickeytk 15y agotabby, I've also updated the article to mention the fact that KEYS may not be a solid use of the system. I would appreciate any feedback!
- tabbyjabby 15y agoSorry, I didn't mean to come across as a dick. I'm glad that you've taken the feedback of your readers into consideration. I'm a big fan of Redis, and it's a key component of our stack. Sorted sets are useful for a lot more than just leader boards, though that is a good use case for them. It's a bit late here, so I'm not feeling up to writing a big post, but I'm considering writing my own blog post on my experiences with Redis.
- dickeytk 15y agoI don't think you were at all. Many people mentioned the same thing you did. I'm new at blogging, so I'm trying to take in everything and produce the best content I can, so I love the feedback! I would love to see a follow-up article too by the way!