org.smallmind.quorum.cache.indigenous
Class AbstractCache<K,V,E extends CacheEntry<V>>

java.lang.Object
  extended by org.smallmind.quorum.cache.LockingCacheEnforcer<K,V>
      extended by org.smallmind.quorum.cache.indigenous.AbstractCache<K,V,E>
All Implemented Interfaces:
LockingCache<K,V>
Direct Known Subclasses:
OrderedCache, UnorderedCache

public abstract class AbstractCache<K,V,E extends CacheEntry<V>>
extends LockingCacheEnforcer<K,V>
implements LockingCache<K,V>


Constructor Summary
AbstractCache(String cacheName, CacheSource<K,V,E> cacheSource, CacheExpirationPolicy<E> cacheExpirationPolicy, int initialCapacity, float loadFactor, int concurrencyLevel, long externalLockTimeout)
           
 
Method Summary
 void clear()
           
 void close()
           
protected  E createNewEntry(K key, Object... parameters)
           
 boolean exists(KeyLock keyLock, K key)
           
protected  E expireEntry(K key)
           
abstract  V get(KeyLock keyLock, K key, Object... parameters)
           
 String getCacheName()
           
protected  E getExistingEntry(KeyLock keyLock, K key)
           
protected  Iterator<K> getKeyIterator()
           
protected  E implantReference(CacheReference<K,E> cacheReference)
           
 boolean isClosed()
           
 V put(KeyLock keyLock, K key, V value)
           
 V putIfAbsent(KeyLock keyLock, K key, V value)
           
abstract  V remove(KeyLock keyLock, K key)
           
protected  E retrieveEntry(KeyLock keyLock, K key)
           
 int size()
           
 void validate(KeyLock keyLock, CacheValidationPolicy<E> cacheValidationPolicy)
           
 
Methods inherited from class org.smallmind.quorum.cache.LockingCacheEnforcer
executeLockedCallback, gateKey, getLockTimeout, getStripeLockArray, lock, lockStripe, unlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.smallmind.quorum.cache.LockingCache
executeLockedCallback, getLockTimeout, lock, unlock
 

Constructor Detail

AbstractCache

public AbstractCache(String cacheName,
                     CacheSource<K,V,E> cacheSource,
                     CacheExpirationPolicy<E> cacheExpirationPolicy,
                     int initialCapacity,
                     float loadFactor,
                     int concurrencyLevel,
                     long externalLockTimeout)
              throws CacheException
Throws:
CacheException
Method Detail

get

public abstract V get(KeyLock keyLock,
                      K key,
                      Object... parameters)
               throws CacheException
Specified by:
get in interface LockingCache<K,V>
Throws:
CacheException

remove

public abstract V remove(KeyLock keyLock,
                         K key)
                  throws CacheException
Specified by:
remove in interface LockingCache<K,V>
Throws:
CacheException

getKeyIterator

protected Iterator<K> getKeyIterator()

expireEntry

protected E expireEntry(K key)

getExistingEntry

protected E getExistingEntry(KeyLock keyLock,
                             K key)
                                            throws CacheException
Throws:
CacheException

createNewEntry

protected E createNewEntry(K key,
                           Object... parameters)
                                          throws CacheException
Throws:
CacheException

retrieveEntry

protected E retrieveEntry(KeyLock keyLock,
                          K key)
                                         throws CacheException
Throws:
CacheException

implantReference

protected E implantReference(CacheReference<K,E> cacheReference)
                                            throws CacheException
Throws:
CacheException

getCacheName

public String getCacheName()
Specified by:
getCacheName in interface LockingCache<K,V>

size

public int size()
Specified by:
size in interface LockingCache<K,V>

clear

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

validate

public void validate(KeyLock keyLock,
                     CacheValidationPolicy<E> cacheValidationPolicy)
              throws CacheException
Throws:
CacheException

exists

public boolean exists(KeyLock keyLock,
                      K key)
               throws CacheException
Specified by:
exists in interface LockingCache<K,V>
Throws:
CacheException

put

public V put(KeyLock keyLock,
             K key,
             V value)
      throws CacheException
Specified by:
put in interface LockingCache<K,V>
Throws:
CacheException

putIfAbsent

public V putIfAbsent(KeyLock keyLock,
                     K key,
                     V value)
Specified by:
putIfAbsent in interface LockingCache<K,V>

isClosed

public boolean isClosed()
Specified by:
isClosed in interface LockingCache<K,V>

close

public void close()
Specified by:
close in interface LockingCache<K,V>


Copyright © 2011. All Rights Reserved.