Class LruCache<Key, Value extends CanEstimateSize>
java.lang.Object
org.postgresql.util.LruCache<Key,Value>
- All Implemented Interfaces:
Gettable<Key,Value>
public class LruCache<Key, Value extends CanEstimateSize>
extends Object
implements Gettable<Key,Value>
Caches values in simple least-recently-accessed order.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceWhen the entry is not present in cache, this create action is used to create one.static interfaceAction that is invoked when the entry is removed from the cache.private class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LruCache.CreateAction<Key, Value> private longprivate final ResourceLockprivate final longprivate final intprivate final LruCache.EvictAction<Value> -
Constructor Summary
ConstructorsConstructorDescriptionLruCache(int maxSizeEntries, long maxSizeBytes, boolean accessOrder) LruCache(int maxSizeEntries, long maxSizeBytes, boolean accessOrder, LruCache.CreateAction<Key, Value> createAction, LruCache.EvictAction<Value> onEvict) -
Method Summary
Modifier and TypeMethodDescriptionBorrows an entry from the cache.private voidevictValue(Value value) Returns an entry from the cache.voidReturns given value to the cache.voidPuts all the values from the given map into the cache.
-
Field Details
-
onEvict
-
createAction
-
maxSizeEntries
private final int maxSizeEntries -
maxSizeBytes
private final long maxSizeBytes -
currentSize
private long currentSize -
cache
-
lock
-
-
Constructor Details
-
LruCache
public LruCache(int maxSizeEntries, long maxSizeBytes, boolean accessOrder) -
LruCache
public LruCache(int maxSizeEntries, long maxSizeBytes, boolean accessOrder, LruCache.CreateAction<Key, Value> createAction, LruCache.EvictAction<Value> onEvict)
-
-
Method Details
-
evictValue
-
get
-
borrow
Borrows an entry from the cache.- Parameters:
key- cache key- Returns:
- entry from cache or newly created entry if cache does not contain given key.
- Throws:
SQLException- if entry creation fails
-
put
-
putAll
-