Commit ec5e51fa authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

1) Optimized #calculateSize to consider Strings

2) Fixed #put to return previous associated value.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@6363 b35dd754-fafc-0310-a699-88a17e54d16e
parent fc109cf4
......@@ -115,7 +115,7 @@ public class Cache<K, V> implements Map<K, V> {
public synchronized V put(K key, V value) {
// Delete an old entry if it exists.
remove(key);
V answer = remove(key);
int objectSize = calculateSize(value);
......@@ -144,7 +144,7 @@ public class Cache<K, V> implements Map<K, V> {
// not too full.
cullCache();
return value;
return answer;
}
public synchronized V get(Object key) {
......@@ -514,6 +514,9 @@ public class Cache<K, V> implements Map<K, V> {
return ((Cacheable)object).getCachedSize();
}
// Check for other common types of objects put into cache.
else if (object instanceof String) {
return CacheSizes.sizeOfString((String)object);
}
else if (object instanceof Long) {
return CacheSizes.sizeOfLong();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment