-
Hi, A wrinkle, on cache miss, we do want to block the data stream pipeline to fetch the latest data from the central cache via the cache wrapper. Refer to details below: I mentioned that I want key to stick around for an "infinite amount of time", by which I meant the lifetime of the app, but I don't mind replacement as long as expired keys can be refreshed in the background and on expiry. I don't want any pauses in data streaming... the caches are needed for stream processing. I was originally planning on writing my own cache manager with each cache implemented as a loading cache, but then I noticed that it's immutable. A long time ago, I wrote a lot of the core caching functionality at Netflix -- I used soft and weak references and built a lot of logic around LInkedHashMap. I don't want to do that all again if there is a better way :-) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 16 replies
-
You can avoid blocking by using Our refresh support is intended to be used with expiration, e.g. to allow active content to stay fresh and inactive content to fade away. A full reload is best suited by a scheduled, period task. The
I'm not sure what you mean by this, but I am also not very familiar with Spring Cache. We don't provide the cache manager and related framework, as it would duplicate efforts of the platform (spring, jcache, custom). It may be that Spring's needs to know all of the caches upfront.
Caffeine is basically a fancy |
Beta Was this translation helpful? Give feedback.
-
RefreshAfterWrite RefreshAfterExpiry Also, I do the load() function execute one time, but only on the first get. I don't see it get called when the entry should have expired or become stale.
|
Beta Was this translation helpful? Give feedback.
-
Ben, I have a question about the unit of the avg_cache_load_penalty. Is it in milliseconds or microseconds? If in milliseconds, the numbers I am seeing don't make sense. For example, 30,000,000 in microseconds would be 30s, but in milliseconds would be 8.3 hours. Also, how is this stat computed within caffeine? I am using the Loading cache with a 5m refresh interval and 3 hour TTL for my cache entries. |
Beta Was this translation helpful? Give feedback.
You can avoid blocking by using
getIfPresent
to obtain the entry or null. TheasMap()
view might also be helpful.Our refresh support is intended to be used with expiration, e.g. to allow active content to stay fresh and inactive content to fade away. A full reload is best suited by a scheduled, period task.
The
cache.get
is an alias forMap.computeIfAbsent
, so you can use that only when helpful for blocking calls.