jaemk / cached

Rust cache structures and easy function memoization
MIT License
1.57k stars 95 forks source link

Shorter namespace for Redis keys #109

Closed jqnatividad closed 2 years ago

jqnatividad commented 2 years ago

RedisStore in 0.32 works like a dream! However, the keys seem to be inordinately long.

Currently, all keys have a namespace prefix of "cached-redis-store". And even if I set a prefix, it's just appended to "cached-redis-store".

Can we make the namespace prefix shorter, say "crs". Also, if I set my own prefix, can it be the namespace on its own and not be appended to a hardcoded prefix?

jaemk commented 2 years ago

hey @jqnatividad , I added an option to the redis builders so you can specify the cache namespace here https://github.com/jaemk/cached/blob/09632ed855462a5a5452b11d30424095d86479cb/src/stores/redis.rs#L77

The cache key construction logic doesn't add any implicit delimiters between namespace/prefix/key so if you want there to be no namespace or no prefix, then you can pass empty strings to the two builder methods (this is also mentioned in the docs of those methods).

released in 0.33.0 (along with your two dependency updates)

jqnatividad commented 2 years ago

Thanks @jaemk ! Works perfectly!