I'm using redis as a primary storage for some data and as a sort of
"L2 cache" for some database(MySQL in my case) entries. The redis data
is saved periodically onto the disk. It works just fine, however there
is a potential stale cache problem:
If server crashes for some reason and gets restarted the redis would
read its state from the disk and possibly stale cache entries.
It would be really nice to mark some keys as "memory-only". Is it
possible somehow?
P.S. when writing this it occurred to me that a possible solution
could be to prefix such keys with some unique string, say, MySQL
server pid...
--
Best regards, Pavel
Sorry, I'm replying to myself. Looks like such a prefix could be the
result of the execution of "lastsave" redis command.
--
Best regards, Pavel
Another solution would be to run two redis instances with different
configurations. Running multiple instances causes very little memory
overhead, so the main downside would be that it's a bit harder to use.
Perhaps you could even implement some generic client side logic for
choosing the correct redis instance for each query.
Cheers,
Hampus
Yep, I was thinking about this one as well. It's a cleaner solution
but a bit more harder to maintain. For now I'll stick to redis
instance related unique prefixes.
--
Best regards, Pavel