(Solved, User Error) Error iterating through Redis keys

After selecting Database one, I am able to set keys that end up propagating, but am unable to retrieve any keys with a SCAN and iterating command. I see in this previous thread that these commands have been enabled.

It’s pretty clear to me that the commands are just responding with an “ok” to everything (like mentioned in your docs).

Is there any way around this? Can I iterate through keys globally or is there some other magic to use for clearing a cache from Database one that I’m not aware of?

I already have “pull” based cache clearing set up so I can just do that.

SCAN will only work on DB 0. DB 1 isn’t actually Redis, it’s a messaging system.

We haven’t implemented FLUSHDB yet but that’s technically how you’d purge Redis.

So am I correct in saying to iterate through keys I need to pull changes rather than push?

What do you mean by “pull changes”?

The best “purge everything” strategy I’ve seen has been a combination of:

  1. TTLs on keys
  2. Cache version in key (like: cache:v2:asdf)
  3. Push current cache version globally
  4. “Purge” by using the new cache version for keys from your app

This is very useful when you have a tremendous number of cache entries. Scan + purge is super slow for more than a few keys, and more useful for targeting purges usually.

@kurt I need to only apply a few changes at a time. A user will update something that’s been cached, and it will only affect a handful of keys in Redis.

As changes occur, I:

  1. Fetch them from each instance
  2. Scan if the key pattern exists in that region’s cache
  3. Delete them if they do.

So I think I’m inline with your best practices you just mentioned.

Ahhh yeah that’ll work well!

Great, thanks. Just wanted to make sure I wasn’t missing the ability to push the changes from my origin rather than pull.