java - Ehcache eternal attribute usage with READ_WRITE objects -
i setting ehcache 2nd level cache hibernate on project. of objects going updated through hibernate , have cache strategy of cacheconcurrencystrategy.read_write. in mind, there should never stale data in cache because if update occurs, object removed cache. no updates database occur outside of application.
my question if when defining caches, setting eternal attribute true makes sense. can't think of reason objects should expire cache , inclined set eternal true. misunderstanding how ehcache behave?
i think depends on several things.
how "long-lived" entities? if deal entities never deleted, living in cache forever, occupying memory. if handled once - in contrast being accessed frequently, makes no sense.
how big caches? overflow disk? memory eviction policy use?
assume restrict cache sizes, putting more & more elements cache cause eviction happen, need think proper eviction policy; poor choices here may cause cache misses can avoided otherwise. may result in disk i/o (depending on configuration) want avoid.
as positive indicators, go eternal caching
- if number of objects cached relatively small , won't exceed cache size
- you restart application (and clear cache) regularly @ small intervals (like daily), such cache size won't hit anyways
- if same objects accessed , can use lru or lfu eviction policy meaningfully
note these more or less rules of thumb; specific situations may require specific evaluation ;)
Comments
Post a Comment