DaveAKing / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Provide API access to details used for Timed Evictions in Caches. #1484

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
From https://groups.google.com/d/topic/guava-discuss/cHPBH_374co/discussion :

When using .expireAfterAccess or .expireAfterWrite, the related timestamps are 
already held within the cache.  I know that we can enumerate all objects in a 
Cache.  I know that we can also use Removal Listeners to receive notifications 
when entries are removed from the cache.  There is also the CacheStats.  
However, the API currently doesn't provide for any method to determine when a 
given entry in the cache is due to expire (assuming nothing else happens to 
cause it to be renewed, etc.).

What I'd like to do is provide a diagnostic / admin UI that shows all of the 
entries currently held in the cache - along with when they were created, and 
when they are due to expire.  I could probably store and maintain my own 
metadata for each entry to be able to determine these details myself - but it 
seems silly to need to duplicate data that is already being maintained 
internally by the Cache.

Additional, helpful notes from Ben Manes:

Expiration is implemented as time ordered queues, where the head is the entry 
most likely to expire. The entries contain a timestamp which is used to 
evaluate for expiration. The traversal of the queues must be done under a lock 
and the cache lacks true global ordering due to using queues per hash table 
segments. For those reasons, exposing an ordered iteration is expensive and not 
currently provided.

That's the background for why this may not be added, but you can open an issue 
and maybe it will be addressed. It could be done by sorting without leveraging 
the queues, which is less elegant but perfectly fine for administration 
purposes.

Original issue reported on code.google.com by ziese...@gmail.com on 19 Jul 2013 at 5:58

GoogleCodeExporter commented 9 years ago

Original comment by lowas...@google.com on 8 Aug 2013 at 10:49

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<issue id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:12

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:08