org.openjena.atlas.lib.cache
Class CacheLRU<K,V>

java.lang.Object
  extended by org.openjena.atlas.lib.cache.CacheLRU<K,V>
All Implemented Interfaces:
Cache<K,V>

public class CacheLRU<K,V>
extends Object
implements Cache<K,V>

This class is not thread-safe. Add a synchronization wrapper if needed (@link{CacheFcatory.createSync)}


Constructor Summary
CacheLRU(float loadFactor, int maxSize)
           
 
Method Summary
 void clear()
           
 boolean containsKey(K key)
          Does the cache contain the key?
 V get(K key)
          Get from cache - or return null.
 boolean isEmpty()
           
 Iterator<K> keys()
          Iterate over all keys.
 V put(K key, V thing)
          Insert into from cache and return old value (or null if none)
 boolean remove(K key)
          Remove from cache - return true if key referenced an entry
 void setDropHandler(ActionKeyValue<K,V> dropHandler)
          Callback for entries when dropped from the cache
 long size()
          Current size of cache
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheLRU

public CacheLRU(float loadFactor,
                int maxSize)
Method Detail

clear

public void clear()
Specified by:
clear in interface Cache<K,V>

containsKey

public boolean containsKey(K key)
Description copied from interface: Cache
Does the cache contain the key?

Specified by:
containsKey in interface Cache<K,V>

get

public V get(K key)
Description copied from interface: Cache
Get from cache - or return null. Implementations should state whether they are thread-safe or not.

Specified by:
get in interface Cache<K,V>

put

public V put(K key,
             V thing)
Description copied from interface: Cache
Insert into from cache and return old value (or null if none)

Specified by:
put in interface Cache<K,V>

remove

public boolean remove(K key)
Description copied from interface: Cache
Remove from cache - return true if key referenced an entry

Specified by:
remove in interface Cache<K,V>

size

public long size()
Description copied from interface: Cache
Current size of cache

Specified by:
size in interface Cache<K,V>

keys

public Iterator<K> keys()
Description copied from interface: Cache
Iterate over all keys. Iteratering over the keys requires the caller be thread-safe.

Specified by:
keys in interface Cache<K,V>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Cache<K,V>

setDropHandler

public void setDropHandler(ActionKeyValue<K,V> dropHandler)
Callback for entries when dropped from the cache

Specified by:
setDropHandler in interface Cache<K,V>


Licenced under the Apache License, Version 2.0