public abstract class SmartCacheImpl<K,V> extends Object implements SmartCache<K,V>
SmartCache
interface which
enforces synchronization with a ReadWrite lock.SmartCache.SmartCacheTask<K,V>
Constructor and Description |
---|
SmartCacheImpl() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the contents of this cache.
|
protected abstract void |
clearImpl() |
void |
execute(SmartCache.SmartCacheTask<K,V> task)
Executes a task over the contents of the cache and guarantees
exclusive write access while processing.
|
V |
get(K key)
Looks up and returns a cache value according to a given key.
|
protected abstract V |
getImpl(K key) |
protected abstract Iterator<Map.Entry<K,V>> |
iteratorImpl()
Must provide an iterator on the contents of the cache.
|
V |
put(K key,
V value)
Places a key/value pair into the cache.
|
protected abstract V |
putImpl(K key,
V value) |
V |
remove(K key)
Removes a key from the cache.
|
protected abstract V |
removeImpl(K key) |
int |
size()
Returns the number of elements in cache.
|
protected abstract int |
sizeImpl() |
protected abstract Iterator<Map.Entry<K,V>> iteratorImpl()
SmartCacheImpl
.protected abstract void clearImpl()
protected abstract int sizeImpl()
public V put(K key, V value)
SmartCache
put
in interface SmartCache<K,V>
key
- Keyvalue
- Valuekey
or nullpublic V get(K key)
SmartCache
null
is returned.get
in interface SmartCache<K,V>
public V remove(K key)
SmartCache
remove
in interface SmartCache<K,V>
key
- Keypublic void clear()
SmartCache
clear
in interface SmartCache<K,V>
public int size()
SmartCache
size
in interface SmartCache<K,V>
public void execute(SmartCache.SmartCacheTask<K,V> task)
SmartCache
execute
in interface SmartCache<K,V>
task
- The task to execute.Copyright © 2020 Hitachi Vantara. All rights reserved.