pinterest / PINCache

Fast, non-deadlocking parallel object cache for iOS, tvOS and OS X
Apache License 2.0
2.66k stars 361 forks source link

Using MemCache as TTL but not disk cache #299

Closed icedice closed 3 years ago

icedice commented 3 years ago

I want to serve the data from the cache without even hitting the backend if it is somewhat fresh. I see two possible way os doing this:

1) Check when item was added to memory cache and serve if fresh. I do however not see anyway of checking when item was added to the cache

2) Use mem cache in TTL mode with short time span. This way I could just serve the item form cache if present. But I don't see any way of putting memory cache into TTL mode without the disk cache doing the same which I do not want.

What am I missing here?


I just noticed that I am able to set TTL on the mem cache like this: memoryCache.setTtl(true) but that the method is deprecated.

garrettmoon commented 3 years ago

Can you explain what use case you need to support where the diskCache being in TTL mode is at odds with your goals?

icedice commented 3 years ago

I honestly do not remember, it was a long time ago but I guess my goal was saving bandwith...