org.specrunner.util.cache
Interface ICache<K,T>

Type Parameters:
K - Key type.
T - The cache object type.
All Known Implementing Classes:
CacheLRU

public interface ICache<K,T>

Cache definition.

Author:
Thiago Santos

Field Summary
static long DEFAULT_FEATURE_CLEAN
          Clean 50 elements.
static long DEFAULT_FEATURE_SIZE
          100 elements cache.
static long DEFAULT_FEATURE_TIMEOUT
          Five minutes cache.
static String FEATURE_CLEAN
          Feature for cache clean.
static String FEATURE_SIZE
          Feature for cache size.
static String FEATURE_TIMEOUT
          Feature for cache timeout.
 
Method Summary
 boolean contains(K key)
          Says if a key is mapped.
 T get(K key)
          Get a cache object.
 ICacheCleaner<T> getCleaner()
          Get the cache cleaner.
 String getName()
          Get the cache name.
 ICache<K,T> put(K key, T value)
          Put an element to the cache.
 void release()
          Release cache.
 void remove(K key)
          Remove an object from cache.
 ICache<K,T> setClean(long clean)
          Set cache number of removed elements on cache overload.
 ICache<K,T> setCleaner(ICacheCleaner<T> cleaner)
          Set the cleaner.
 ICache<K,T> setName(String name)
          Set a cache name.
 ICache<K,T> setSize(long size)
          Set cache max size.
 ICache<K,T> setTimeout(long timeout)
          Set cache elements timeout.
 

Field Detail

FEATURE_TIMEOUT

static final String FEATURE_TIMEOUT
Feature for cache timeout.


DEFAULT_FEATURE_TIMEOUT

static final long DEFAULT_FEATURE_TIMEOUT
Five minutes cache.

See Also:
Constant Field Values

FEATURE_SIZE

static final String FEATURE_SIZE
Feature for cache size.


DEFAULT_FEATURE_SIZE

static final long DEFAULT_FEATURE_SIZE
100 elements cache.

See Also:
Constant Field Values

FEATURE_CLEAN

static final String FEATURE_CLEAN
Feature for cache clean.


DEFAULT_FEATURE_CLEAN

static final long DEFAULT_FEATURE_CLEAN
Clean 50 elements.

See Also:
Constant Field Values
Method Detail

getName

String getName()
Get the cache name.

Returns:
The name.

setName

ICache<K,T> setName(String name)
Set a cache name.

Parameters:
name - A cache.
Returns:
The cache itself.

getCleaner

ICacheCleaner<T> getCleaner()
Get the cache cleaner.

Returns:
The cleaner.

setCleaner

ICache<K,T> setCleaner(ICacheCleaner<T> cleaner)
Set the cleaner.

Parameters:
cleaner - A cleaner.
Returns:
The cache itself.

setTimeout

ICache<K,T> setTimeout(long timeout)
Set cache elements timeout.

Parameters:
timeout - The timeout.
Returns:
The cache itself.

setSize

ICache<K,T> setSize(long size)
Set cache max size.

Parameters:
size - The size.
Returns:
The cache itself.

setClean

ICache<K,T> setClean(long clean)
Set cache number of removed elements on cache overload.

Parameters:
clean - The number of items to be removed.
Returns:
The cache itself.

contains

boolean contains(K key)
Says if a key is mapped.

Parameters:
key - The key.
Returns:
true, if mapped, false, otherwise.

get

T get(K key)
Get a cache object.

Parameters:
key - The object key.
Returns:
A object, if an entry exists and is not out of date, null, otherwise.

put

ICache<K,T> put(K key,
                T value)
Put an element to the cache.

Parameters:
key - The key.
value - The object value.
Returns:
The cache itself.

remove

void remove(K key)
Remove an object from cache.

Parameters:
key - The key.

release

void release()
Release cache.



Copyright © 2014. All rights reserved.