org.neo4j.kernel.impl.cache
Interface Cache<K,V>

All Known Implementing Classes:
LruCache, NoCache, ReferenceCache, SoftLruCache, StrongReferenceCache, WeakLruCache

public interface Cache<K,V>

Simple cache interface with add, remove, get, clear and size methods. If null is passed as parameter an IllegalArgumentException is thrown.

If the cache cleans it self (for example a LIFO cache with maximum size) the elementCleaned method is invoked. Override the default implementation (that does nothing) if needed.

TODO: Create a pluggable, scalable, configurable, self analyzing/adaptive, statistics/reportable cache architecture. Emil will code that in four hours when he has time.


Method Summary
 void clear()
          Removing all cached elements.
 void elementCleaned(V value)
           
 V get(K key)
          Returns the cached element for key.
 String getName()
          Returns the name of the cache.
 long hitCount()
           
 boolean isAdaptive()
           
 int maxSize()
           
 long missCount()
           
 void put(K key, V value)
          Adds element to cache.
 void putAll(Map<K,V> map)
           
 V remove(K key)
          Removes the element for key from cache and returns it.
 void resize(int newSize)
           
 void setAdaptiveStatus(boolean status)
           
 int size()
          Returns the cache size.
 

Method Detail

getName

String getName()
Returns the name of the cache.

Returns:
name of the cache

put

void put(K key,
         V value)
Adds element to cache.

Parameters:
key - the key for the element
element - the element to cache

remove

V remove(K key)
Removes the element for key from cache and returns it. If the no element for key exists null is returned.

Parameters:
key - the key for the element
Returns:
the removed element or null if element didn't exist

get

V get(K key)
Returns the cached element for key. If the element isn't in cache null is returned.

Parameters:
key - the key for the element
Returns:
the cached element or null if element didn't exist

clear

void clear()
Removing all cached elements.


size

int size()
Returns the cache size.

Returns:
cache size

elementCleaned

void elementCleaned(V value)

maxSize

int maxSize()

resize

void resize(int newSize)

isAdaptive

boolean isAdaptive()

setAdaptiveStatus

void setAdaptiveStatus(boolean status)

putAll

void putAll(Map<K,V> map)

hitCount

long hitCount()

missCount

long missCount()


Copyright © 2002-2012 The Neo4j Graph Database Project. All Rights Reserved.