Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 780189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:02:13+00:00 2026-05-14T20:02:13+00:00

Is there any to specify a data refresh policy in Ehcache ? I am

  • 0

Is there any to specify a data refresh policy in Ehcache? I am currently migrating an application from OSCache to Ehcache and I can’t seem to find any way to specify when an element needs refreshing, besides setting timeToIdle and timeToLive.

What I want is: on accessing an element from the cache, check with it’s associated resource to see if it was updated later than the lastUpdateTime of the cache element. If yes, refresh the cache; else serve the content from the cache.

In OSCache this was done by catching NeedsRefreshExceptions and setting custom refresh policies for the elements. I’ve been digging around in the docs for a while now, but I wasn’t able to find any methods or examples of how I could accomplish this in Ehcache.

Any help would be appreciated :).

Alex

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T20:02:14+00:00Added an answer on May 14, 2026 at 8:02 pm

    The OSCache’s idea of NeedsRefreshException is really flawed. First, this goes against the advice to use exceptions for usual execution flow (and yes, I do consider stale cache hit as a normal flow); secondly creating exception for this is really expensive.

    Now back to your question. If I was in your shoes, I would evaluate the possibility either to extend net.sf.ehcache.Element, or wrap your entry value into an object which would be able to check the timeToLive.

    But the main question is, why do you need to do that? If you are putting object into the cache and specifying the TTL, why bother checking the TTL on retrieval? The cache should be able to evict the object without any external help. Same applies for cases when you manually remove the entry (e.g. when the object has been changed). Maybe I am missing something here?

    The feature you’re asking about is called read-through. How to do this is explained here: http://ehcache.org/documentation/concepts.html#read-through

    —

    another unhappy OSCache user waiting to migrate to EHCache 🙁

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there any way we can specify the buffering data size for the element?
Is there any way I can use JPA or hibernate annotations to specify the
Is there any way in Knockoutjs binding where I can specify optionsGroup ? something
Is there any official write-up what forms can Data Source field take in sql
Is there any difference if I specify vertex/color data through glVertexPointer/glColorPointer Using glMapBufferOES (extension)
Is there any attribute in jQueryMobile where I can specify that I don't to
Is there any way to specify table column width as is. In other words,
Is there any way to specify that a function should be called when a
Is there any way to specify a width when doing :vsplit? Also, is there
Is there any way to specify optional parameters (such as when search parameters are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.