-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Faq
A pinned entry is one that cannot be removed by an eviction policy. This is useful when the entry is a stateful resource, like a lock, that can only be discarded after the client has released finished using it. In those cases the behavior of evicting an entry and recomputing it would cause a resource leak.
An entry can be excluded from maximum size eviction by using weights and evaluating the entry to a weight of zero. The entry then does not count towards the overall capacity and is skipped by the maximum size eviction. A custom Weigher
must be defined that can evaluate if the entry as pinned.
An entry can be excluded from expiration by using a duration of Long.MAX_VALUE
, or roughly 300 years. A custom Expiry
must be defined that can evaluate if the entry as pinned.
The weight and expiration are evaluated when the entry is written into the cache. This can be accomplished using cache.asMap().compute
to pin and unpin the entry.