Package org.kairosdb.bigqueue.cache
Interface ILRUCache<K,V extends Closeable>
-
- Type Parameters:
K- the keyV- the value
- All Known Implementing Classes:
LRUCacheImpl
public interface ILRUCache<K,V extends Closeable>LRU cache ADT- Author:
- bulldog
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Vget(K key)Get a cached resource with specific key This call will increment the reference counter of the keyed resource.Collection<V>getValues()All values cachedvoidput(K key, V value)Put a keyed resource with default ttl into the cache This call will increment the reference counter of the keyed resource.voidput(K key, V value, long ttlInMilliSeconds)Put a keyed resource with specific ttl into the cache This call will increment the reference counter of the keyed resource.voidrelease(K key)Release the cached resource with specific key This call will decrement the reference counter of the keyed resource.Vremove(K key)Remove the resource with specific key from the cache and close it synchronously afterwards.voidremoveAll()Remove all cached resource from the cache and close them asynchronously afterwards.intsize()The size of the cache, equals to current total number of cached resources.
-
-
-
Method Detail
-
put
void put(K key, V value, long ttlInMilliSeconds)
Put a keyed resource with specific ttl into the cache This call will increment the reference counter of the keyed resource.- Parameters:
key- the key of the cached resourcevalue- the to be cached resourcettlInMilliSeconds- time to live in milliseconds
-
put
void put(K key, V value)
Put a keyed resource with default ttl into the cache This call will increment the reference counter of the keyed resource.- Parameters:
key- the key of the cached resourcevalue- the to be cached resource
-
get
V get(K key)
Get a cached resource with specific key This call will increment the reference counter of the keyed resource.- Parameters:
key- the key of the cached resource- Returns:
- cached resource if exists
-
release
void release(K key)
Release the cached resource with specific key This call will decrement the reference counter of the keyed resource.- Parameters:
key- key of resource to release
-
remove
V remove(K key) throws IOException
Remove the resource with specific key from the cache and close it synchronously afterwards.- Parameters:
key- the key of the cached resource- Returns:
- the removed resource if exists
- Throws:
IOException- exception thrown if there is any IO error
-
removeAll
void removeAll() throws IOExceptionRemove all cached resource from the cache and close them asynchronously afterwards.- Throws:
IOException- exception thrown if there is any IO error
-
size
int size()
The size of the cache, equals to current total number of cached resources.- Returns:
- the size of the cache
-
getValues
Collection<V> getValues()
All values cached- Returns:
- a collection
-
-