UltraMiniRedis: Implement basic redis-like temporary cache or not?

I'm on a dilemma on whether implement a basic, redis-like, temporary cache with TTL (Let's call it UltraMiniRedis) using tokio sync primitives, or just discard the idea and go for the real Redis, which sounds overkill since I just need that basic functionality.

If I go with the implementation, I'm planning on using the RwLock on a HashMap, and using an interval to remove the stale entries. It's particularly the usage of the interval that makes me question the viability of it.

Any thoughts on this? I was also considering Jon Gjengset's Concurrent HashMap, but bringing a dependency would be going against the idea of not using external dependencies. Same goes for mini-redis, hence the mocking title, since I just want to be able to check if something is in the cache to avoid unnecessary database lookups.

Have you seen mini-redis? It does something very similar, although it uses a Mutex rather than RwLock.

Edit: I see that you mentioned it :sweat_smile:

You could certainly use the same strategy as mini-redis for an in-memory cache.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.