In the code we can see the method put with 'seconds_to_store' value.
But here the 'seconds_to_store' value is added to miliseconds
/* --- code --- */
public void put(Object key, Object val, Integer seconds_to_store) {
/* ... */
seconds_to_store = seconds_to_store != null ? seconds_to_store : 9999999;
cache.put(key, new Object[]{System.currentTimeMillis() + seconds_to_store, val});
Later, it is compared to miliseconds again
/* --- code --- */
public Object get(Object key) {
/* ... */
Long expires = (Long) cache.get(key)[0];
if (expires - System.currentTimeMillis() > 0) {
My 2cents. solution
public void put(Object key, Object val, Integer seconds_to_store) {
/* ... */
seconds_to_store =System.currentTimeMillis() + 1000L*(seconds_to_store != null ? seconds_to_store : 9999999);
cache.put(key, new Object[]{seconds_to_store, val});
Other thing that can improve, no need to substract
/* --- code --- */
public Object get(Object key) {
/* ... */
Long expires = (Long) cache.get(key)[0];
if (expires > System.currentTimeMillis() ) {
Original issue reported on code.google.com by obe...@gmail.com on 17 Jun 2011 at 9:39
Original issue reported on code.google.com by
obe...@gmail.com
on 17 Jun 2011 at 9:39