ch.bind.philib.cache
Interface Cache<K,V>

All Known Implementing Classes:
LineCache, LruCache, StagedLruCache

public interface Cache<K,V>

The base interface for a cache implementation.

Author:
Philipp Meinen

Field Summary
static int DEFAULT_CAPACITY
          The default capacity of an object cache.
 
Method Summary
 int capacity()
           
 void clear()
          Remove all elements from the cache.
 V get(K key)
          Query a value from the cache by its key.
 void remove(K key)
          Remove a key-value-pair from the cache.
 void set(K key, V value)
          Sets a key-value-pair to the cache.
 

Field Detail

DEFAULT_CAPACITY

static final int DEFAULT_CAPACITY
The default capacity of an object cache.

See Also:
Constant Field Values
Method Detail

set

void set(K key,
         V value)
Sets a key-value-pair to the cache.

Throws:
IllegalArgumentException - if the key is null.

get

V get(K key)
Query a value from the cache by its key.

Returns:
null if no value for the given key was found. Otherwise the value for this key.
Throws:
IllegalArgumentException - if the key is null.

remove

void remove(K key)
Remove a key-value-pair from the cache.

Throws:
IllegalArgumentException - if the key is null.

capacity

int capacity()
Returns:
the capacity of this cache.

clear

void clear()
Remove all elements from the cache.



Copyright © 2013. All Rights Reserved.