@ThreadSafe public class SynchronizedLruCache extends Object implements org.springframework.cache.Cache
Cache implementation with adjustable capacity limit
based on LinkedHashMap from JDK.| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_INITIAL_CAPACITY |
static float |
DEFAULT_LOAD_FACTOR |
| Constructor and Description |
|---|
SynchronizedLruCache(String name,
int capacity)
Create a new instance with default initial capacity and load factor.
|
SynchronizedLruCache(String name,
int capacity,
int initialCapacity,
float loadFactory) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
protected org.springframework.cache.Cache.ValueWrapper |
createEntry(Object value) |
void |
evict(Object key) |
org.springframework.cache.Cache.ValueWrapper |
get(Object key) |
String |
getName() |
LinkedHashMap |
getNativeCache() |
void |
put(Object key,
Object value) |
public static final int DEFAULT_INITIAL_CAPACITY
public static final float DEFAULT_LOAD_FACTOR
public SynchronizedLruCache(String name, int capacity)
name - An arbitrary name of this cache instance.capacity - The maximal capacity.public SynchronizedLruCache(String name, int capacity, int initialCapacity, float loadFactory)
public String getName()
getName in interface org.springframework.cache.Cachepublic LinkedHashMap getNativeCache()
getNativeCache in interface org.springframework.cache.Cachepublic org.springframework.cache.Cache.ValueWrapper get(Object key)
get in interface org.springframework.cache.Cachepublic void put(Object key, Object value)
put in interface org.springframework.cache.Cachepublic void evict(Object key)
evict in interface org.springframework.cache.Cachepublic void clear()
clear in interface org.springframework.cache.Cacheprotected org.springframework.cache.Cache.ValueWrapper createEntry(Object value)
Copyright © 2014. All rights reserved.