public class ReadWriteCache extends Object implements CacheConcurrencyStrategy
for a faster algorithm
,
CacheConcurrencyStrategy
Modifier and Type | Class and Description |
---|---|
static class |
ReadWriteCache.Item
An item of cached data, timestamped with the time it was cached,.
|
static class |
ReadWriteCache.Lock
A soft lock which supports concurrent locking,
timestamped with the time it was released
|
static interface |
ReadWriteCache.Lockable |
Constructor and Description |
---|
ReadWriteCache() |
Modifier and Type | Method and Description |
---|---|
boolean |
afterInsert(Object key,
Object value,
Object version)
Add the new item to the cache, checking that no other transaction has
accessed the item.
|
boolean |
afterUpdate(Object key,
Object value,
Object version,
SoftLock clientLock)
Re-cache the updated state, if and only if there there are
no other concurrent soft locks.
|
void |
clear()
Evict all items from the cache immediately.
|
void |
destroy()
Clean up all resources.
|
void |
evict(Object key)
Do nothing.
|
Object |
get(Object key,
long txTimestamp)
Do not return an item whose timestamp is later than the current
transaction timestamp.
|
Cache |
getCache()
Get the wrapped cache implementation
|
String |
getRegionName()
Get the cache region name
|
boolean |
insert(Object key,
Object value,
Object currentVersion)
Do nothing.
|
SoftLock |
lock(Object key,
Object version)
Stop any other transactions reading or writing this item to/from
the cache.
|
boolean |
put(Object key,
Object value,
long txTimestamp,
Object version,
Comparator versionComparator,
boolean minimalPut)
Do not add an item to the cache unless the current transaction
timestamp is later than the timestamp at which the item was
invalidated.
|
void |
release(Object key,
SoftLock clientLock)
Release the soft lock on the item.
|
void |
remove(Object key)
Evict an item from the cache immediately (without regard for transaction
isolation).
|
void |
setCache(Cache cache)
Set the underlying cache implementation.
|
String |
toString() |
boolean |
update(Object key,
Object value,
Object currentVersion,
Object previousVersion)
Do nothing.
|
public void setCache(Cache cache)
CacheConcurrencyStrategy
setCache
in interface CacheConcurrencyStrategy
public Cache getCache()
CacheConcurrencyStrategy
getCache
in interface CacheConcurrencyStrategy
public String getRegionName()
CacheConcurrencyStrategy
getRegionName
in interface CacheConcurrencyStrategy
public Object get(Object key, long txTimestamp) throws CacheException
get
in interface CacheConcurrencyStrategy
txTimestamp
- a timestamp prior to the transaction start timeCacheException
public SoftLock lock(Object key, Object version) throws CacheException
lock
in interface CacheConcurrencyStrategy
CacheException
public boolean put(Object key, Object value, long txTimestamp, Object version, Comparator versionComparator, boolean minimalPut) throws CacheException
put
in interface CacheConcurrencyStrategy
txTimestamp
- a timestamp prior to the transaction start timeversion
- the item version numberversionComparator
- a comparator used to compare version numbersminimalPut
- indicates that the cache should avoid a put is the item is already cachedCacheException
public void release(Object key, SoftLock clientLock) throws CacheException
release
in interface CacheConcurrencyStrategy
CacheException
public void clear() throws CacheException
CacheConcurrencyStrategy
clear
in interface CacheConcurrencyStrategy
CacheException
public void remove(Object key) throws CacheException
CacheConcurrencyStrategy
remove
in interface CacheConcurrencyStrategy
CacheException
public void destroy()
CacheConcurrencyStrategy
destroy
in interface CacheConcurrencyStrategy
public boolean afterUpdate(Object key, Object value, Object version, SoftLock clientLock) throws CacheException
afterUpdate
in interface CacheConcurrencyStrategy
CacheException
public boolean afterInsert(Object key, Object value, Object version) throws CacheException
afterInsert
in interface CacheConcurrencyStrategy
CacheException
public void evict(Object key) throws CacheException
evict
in interface CacheConcurrencyStrategy
CacheException
public boolean insert(Object key, Object value, Object currentVersion)
insert
in interface CacheConcurrencyStrategy
public boolean update(Object key, Object value, Object currentVersion, Object previousVersion)
update
in interface CacheConcurrencyStrategy
Copyright © 2002-2017 Red Hat Middleware, LLC. All Rights Reserved