Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It seems that what you need is a <strong>time-based eviction cache.</strong><br> Take a look at <a href="http://code.google.com/p/guava-libraries/wiki/CachesExplained#Timed_Eviction" rel="nofollow">Google Guava Cache library:</a></p> <blockquote> <p>CacheBuilder provides two approaches to timed eviction:</p> <ul> <li><strong>expireAfterAccess(long duration, TimeUnit unit)</strong> Only expire entries after the specified duration has passed since the entry was last accessed by a read or a write. Note that the order in which entries are evicted will be similar to that of size-based eviction.</li> <li><strong>expireAfterWrite(long duration, TimeUnit unit)</strong> Expire entries after the specified duration has passed since the entry was created, or the most recent replacement of the value. This could be desirable if cached data grows stale after a certain amount of time. </li> </ul> </blockquote> <p>So which approach do you need? You said: </p> <blockquote> <p>I'd like it to call the database and refresh its data every time it is accessed AND <strong>a certain amount of time has passed.</strong></p> </blockquote> <p>A certain amount of time has passed since when?</p> <ul> <li>Since entry was last read from your cache? It doesn't matter how much time has passed since entry was loaded from database? Then use <strong>expireAfterAccess()</strong></li> <li>Since entry was last loaded from database into your cache? Then use <strong>expireAfterWrite()</strong></li> </ul> <p>You can even use them both at the same time.<br> Here is such example: <a href="http://mkorytin.blogspot.com/2012/02/caching-objects-with-guava.html" rel="nofollow">http://mkorytin.blogspot.com/2012/02/caching-objects-with-guava.html</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload