org.axonframework.cache
Class NoCache

java.lang.Object
  extended by org.axonframework.cache.NoCache
All Implemented Interfaces:
Cache

public final class NoCache
extends Object
implements Cache

Cache implementation that does absolutely nothing. Objects aren't cached, making it a special case implementation for the case when caching is disabled.

Since:
0.3
Author:
Allard Buijze

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.axonframework.cache.Cache
Cache.EntryListener, Cache.EntryListenerAdapter
 
Field Summary
static NoCache INSTANCE
          Creates a singleton reference the the NoCache implementation.
 
Method Summary
 boolean containsKey(Object key)
          Indicates whether there is an item stored under given key.
<K,V> V
get(K key)
          Returns an item from the cache, or null if no item was stored under that key
 void put(Object key, Object value)
          Stores the given value in the cache, under given key.
 boolean putIfAbsent(Object key, Object value)
          Stores the given value in the cache, under given key, if no element is yet available under that key.
 void registerCacheEntryListener(Cache.EntryListener cacheEntryListener)
          Registers the given cacheEntryListener to listen for Cache changes.
 boolean remove(Object key)
          Removes the entry stored under given key.
 void unregisterCacheEntryListener(Cache.EntryListener cacheEntryRemovedListener)
          Unregisters the previously registered cacheEntryListener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final NoCache INSTANCE
Creates a singleton reference the the NoCache implementation.

Method Detail

get

public <K,V> V get(K key)
Description copied from interface: Cache
Returns an item from the cache, or null if no item was stored under that key

Specified by:
get in interface Cache
Type Parameters:
K - The type of key used
V - The type of value stored
Parameters:
key - The key under which the item was cached
Returns:
the item stored under the given key

put

public void put(Object key,
                Object value)
Description copied from interface: Cache
Stores the given value in the cache, under given key. If an item already exists, it is updated with the new value.

Specified by:
put in interface Cache
Parameters:
key - The key under which to store the item
value - The item to cache

putIfAbsent

public boolean putIfAbsent(Object key,
                           Object value)
Description copied from interface: Cache
Stores the given value in the cache, under given key, if no element is yet available under that key. This operation is performed atomically.

Specified by:
putIfAbsent in interface Cache
Parameters:
key - The key under which to store the item
value - The item to cache
Returns:
true if no value was previously assigned to the key, false otherwise.

remove

public boolean remove(Object key)
Description copied from interface: Cache
Removes the entry stored under given key. If no such entry exists, nothing happens.

Specified by:
remove in interface Cache
Parameters:
key - The key under which the item was stored
Returns:
true if a value was previously assigned to the key and has been removed, false otherwise.

containsKey

public boolean containsKey(Object key)
Description copied from interface: Cache
Indicates whether there is an item stored under given key.

Specified by:
containsKey in interface Cache
Parameters:
key - The key to check
Returns:
true if an item is available under that key, false otherwise.

registerCacheEntryListener

public void registerCacheEntryListener(Cache.EntryListener cacheEntryListener)
Description copied from interface: Cache
Registers the given cacheEntryListener to listen for Cache changes.

Specified by:
registerCacheEntryListener in interface Cache
Parameters:
cacheEntryListener - The listener to register

unregisterCacheEntryListener

public void unregisterCacheEntryListener(Cache.EntryListener cacheEntryRemovedListener)
Description copied from interface: Cache
Unregisters the previously registered cacheEntryListener.

Specified by:
unregisterCacheEntryListener in interface Cache
Parameters:
cacheEntryRemovedListener - The listener to unregister


Copyright © 2010-2016. All Rights Reserved.