org.apache.lucene.util.cache
Class SimpleMapCache<K,V>

java.lang.Object
  extended by org.apache.lucene.util.cache.Cache<K,V>
      extended by org.apache.lucene.util.cache.SimpleMapCache<K,V>
All Implemented Interfaces:
Closeable
Direct Known Subclasses:
SimpleLRUCache

public class SimpleMapCache<K,V>
extends Cache<K,V>

Simple cache implementation that uses a HashMap to store (key, value) pairs. This cache is not synchronized, use Cache.synchronizedCache(Cache) if needed.


Field Summary
protected  Map<K,V> map
           
 
Constructor Summary
SimpleMapCache()
           
SimpleMapCache(Map<K,V> map)
           
 
Method Summary
 void close()
          Closes the cache.
 boolean containsKey(Object key)
          Returns whether the given key is in this cache.
 V get(Object key)
          Returns the value for the given key.
 Set<K> keySet()
          Returns a Set containing all keys in this cache.
 void put(K key, V value)
          Puts a (key, value)-pair into the cache.
 
Methods inherited from class org.apache.lucene.util.cache.Cache
synchronizedCache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

map

protected Map<K,V> map
Constructor Detail

SimpleMapCache

public SimpleMapCache()

SimpleMapCache

public SimpleMapCache(Map<K,V> map)
Method Detail

get

public V get(Object key)
Description copied from class: Cache
Returns the value for the given key.

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

put

public void put(K key,
                V value)
Description copied from class: Cache
Puts a (key, value)-pair into the cache.

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

close

public void close()
Description copied from class: Cache
Closes the cache.

Specified by:
close in interface Closeable
Specified by:
close in class Cache<K,V>

containsKey

public boolean containsKey(Object key)
Description copied from class: Cache
Returns whether the given key is in this cache.

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

keySet

public Set<K> keySet()
Returns a Set containing all keys in this cache.



Copyright © 2000-2010 Apache Software Foundation. All Rights Reserved.