|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectgoldengate.common.lru.AbstractLruCache<K,V>
goldengate.common.lru.SynchronizedLruCache<K,V>
public class SynchronizedLruCache<K,V>

Threadsafe synchronized implementation of LruCache based on LinkedHashMap. Threadsafety is provided by method synchronization. This cache implementation should be used with low number of threads.
| Field Summary | |
|---|---|
static int |
DEFAULT_INITIAL_CAPACITY
|
static float |
DEFAULT_LOAD_FACTOR
|
| Constructor Summary | |
|---|---|
SynchronizedLruCache(int capacity,
long ttl)
Creates new SynchronizedLruCache with DEFAULT_LOAD_FACTOR and DEFAULT_INITIAL_CAPACITY |
|
SynchronizedLruCache(int capacity,
long ttl,
int initialCapacity)
Creates new SynchronizedLruCache with DEFAULT_LOAD_FACTOR |
|
SynchronizedLruCache(int capacity,
long ttl,
int initialCapacity,
float loadFactor)
Creates new SynchronizedLruCache |
|
| Method Summary | |
|---|---|
void |
clear()
Removes all entries from cache |
void |
forceClearOldest()
Removes all oldest entries from cache (ttl based) |
V |
get(K key)
Returns value cached with key. |
int |
getCapacity()
Returns cache capacity |
protected InterfaceLruCacheEntry<V> |
getEntry(K key)
Returns LruCacheEntry mapped by key or null if it does not exist |
int |
getSize()
Returns number of entries stored in cache (including invalid ones) |
void |
put(K key,
V value,
long ttl)
Puts value under key into cache with desired TTL |
protected void |
putEntry(K key,
InterfaceLruCacheEntry<V> entry)
Puts entry into cache |
void |
remove(K key)
Removes entry from cache (if exists) |
| Methods inherited from class goldengate.common.lru.AbstractLruCache |
|---|
contains, createEntry, get, get, getTtl, getValue, isEmpty, put |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_INITIAL_CAPACITY
public static final float DEFAULT_LOAD_FACTOR
| Constructor Detail |
|---|
public SynchronizedLruCache(int capacity,
long ttl,
int initialCapacity,
float loadFactor)
capacity - max cache capacityttl - time to live in millisecondsinitialCapacity - initial cache capacityloadFactor -
public SynchronizedLruCache(int capacity,
long ttl,
int initialCapacity)
capacity - max cache capacityttl - time to live in millisecondsinitialCapacity - initial cache capacity
public SynchronizedLruCache(int capacity,
long ttl)
capacity - max cache capacityttl - time to live in milliseconds| Method Detail |
|---|
public void clear()
InterfaceLruCache
public V get(K key)
InterfaceLruCache
get in interface InterfaceLruCache<K,V>get in class AbstractLruCache<K,V>public int getCapacity()
InterfaceLruCache
protected InterfaceLruCacheEntry<V> getEntry(K key)
AbstractLruCache
getEntry in class AbstractLruCache<K,V>public int getSize()
InterfaceLruCache
public void put(K key,
V value,
long ttl)
InterfaceLruCache
put in interface InterfaceLruCache<K,V>put in class AbstractLruCache<K,V>ttl - time to live in milliseconds
protected void putEntry(K key,
InterfaceLruCacheEntry<V> entry)
AbstractLruCache
putEntry in class AbstractLruCache<K,V>public void remove(K key)
InterfaceLruCache
public void forceClearOldest()
InterfaceLruCache
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||