When adding a new item beyond the size limite it seems that tries to remove the
oldest object in, but the code is not expressin that. Instead it tries to
remove the same key that was trying to put
if (toRemove != null) {
remove(key);
}
all the code...
public void put(Object key, Object val, Integer seconds_to_store) {
if(key == null) throw new RuntimeException("Key cannot be null!");
seconds_to_store = seconds_to_store != null ? seconds_to_store : 9999999;
cache.put(key, new Object[]{System.currentTimeMillis() + seconds_to_store, val});
queue.add(key);
size.incrementAndGet();
while (size.get() > maxSize && maxSize > 0) {
Object toRemove = queue.poll();
if(toRemove == null) break;
// System.out.println("toRemove=" + toRemove + " size=" + size.get()
+ " maxSize=" + maxSize);
if (toRemove != null) {
remove(key);
}
}
}
am I miss understanding?
Federico
Original issue reported on code.google.com by federico...@gmail.com on 17 Feb 2011 at 4:39
Original issue reported on code.google.com by
federico...@gmail.com
on 17 Feb 2011 at 4:39