com.atlassian.jira.util
Class ConcurrentCacheMap<K,V>

java.lang.Object
  extended by com.atlassian.jira.util.ConcurrentCacheMap<K,V>
All Implemented Interfaces:
CacheMap<K,V>

public class ConcurrentCacheMap<K,V>
extends Object
implements CacheMap<K,V>

An implementation of CacheMap that allows null keys and values.

The data is stored in a ConcurrentHashMap giving it high throughput under load. It uses a special token to transparently store null keys and values which are not natively supported by ConcurrentHashMap.

Since:
v4.0

Constructor Summary
ConcurrentCacheMap()
           
 
Method Summary
 void clear()
          Removes all of the mappings from this cache.
 Collection<V> copyOfValues()
          Returns a Collection view of the values contained in this cache.
 V get(K key)
          Returns the value to which the specified key is mapped, or null if this cache contains no mapping for the key.
 void put(K key, V value)
          Maps the specified key to the specified value in this cache.
 void remove(K key)
          Removes the key (and its corresponding value) from this cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConcurrentCacheMap

public ConcurrentCacheMap()
Method Detail

get

public V get(K key)
Description copied from interface: CacheMap
Returns the value to which the specified key is mapped, or null if this cache contains no mapping for the key.

Specified by:
get in interface CacheMap<K,V>
Parameters:
key - the key.
Returns:
the value to which the specified key is mapped.

put

public void put(K key,
                V value)
Description copied from interface: CacheMap
Maps the specified key to the specified value in this cache.

The value can be retrieved by calling the get method with a key that is equal to the original key.

Specified by:
put in interface CacheMap<K,V>
Parameters:
key - key with which the specified value is to be associated
value - value to be associated with the specified key

clear

public void clear()
Description copied from interface: CacheMap
Removes all of the mappings from this cache.

Specified by:
clear in interface CacheMap<K,V>

remove

public void remove(K key)
Description copied from interface: CacheMap
Removes the key (and its corresponding value) from this cache. This method does nothing if the key is not in the cache.

Specified by:
remove in interface CacheMap<K,V>
Parameters:
key - the key that needs to be removed

copyOfValues

public Collection<V> copyOfValues()
Description copied from interface: CacheMap
Returns a Collection view of the values contained in this cache.

The collection is a copy of the values that were contained at the time that this operation was called. Concurrent implementations of this interface will likely allow mutating operations to occur while the collection is being constructed, and which of these modifications are in the resulting collection will be timing and implementation dependant.

Specified by:
copyOfValues in interface CacheMap<K,V>
Returns:
a Collection view of the values contained in this cache.


Copyright © 2002-2014 Atlassian. All Rights Reserved.