dnrajugade / guava-libraries

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

Allow customized expiry time for cache entry #1203

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Allow per entry expiry time for caches built with expireAfterWrite / 
expireAfterAccess (something like put(K key, V value, long timeout).

Original issue reported on code.google.com by nika...@gmail.com on 14 Nov 2012 at 11:01

GoogleCodeExporter commented 9 years ago

Original comment by wasserman.louis on 14 Nov 2012 at 4:43

GoogleCodeExporter commented 9 years ago
Wait.  Wouldn't you want that only if the cache was *not* built with 
expireAfterWrite/expireAfterAccess?

In any event, this seems really awkward from an API perspective, in addition to 
being problematic from an implementation point of view.  In particular, 
customized expiration times more or less require you to use an O(log n) 
priority queue, as opposed to the current O(1) implementation that is possible 
when you can just maintain a linked list of most recently written or most 
recently accessed.

Original comment by lowas...@google.com on 20 Dec 2012 at 8:18

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 12 Mar 2013 at 6:43

GoogleCodeExporter commented 9 years ago
fyi,

You wouldn't use a priority queue w/ O(lg n) insertion and removal. Instead 
you'd require an expected range for expiration times and a resolution (e.g. 
1..60 in minutes). This would allow you to a create an array of linked list 
(e.g. a bounded height priority queue) so that add/remove/reorder is O(1). The 
penalty would be O(r) of scanning the first element in every slot to see if an 
eviction is required.

The API would still be awkward, even more so than the O(lg n) version 
requested, but would be much cheaper to maintain.

(Not advocating, but mentioning as this feature is often requested)

Original comment by Ben.Manes@gmail.com on 21 Aug 2013 at 5:01

GoogleCodeExporter commented 9 years ago

Original comment by kak@google.com on 22 Aug 2013 at 11:29

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

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

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

GoogleCodeExporter commented 9 years ago

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

GoogleCodeExporter commented 9 years ago

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