interface ConcurrentRegion implements Region (View source)

Defines contract for concurrently managed data region.

It should be able to lock an specific cache entry in an atomic operation.

When a entry is locked another process should not be able to read or write the entry. All evict operation should not consider locks, even though an entry is locked evict should be able to delete the entry and its lock.

Methods

CacheEntry[]|null
getMultiple(CollectionCacheEntry $collection)

Get all items from the cache identified by $keys.

string
getName()

Retrieve the name of this region.

from Region
boolean
contains(CacheKey $key)

Determine whether this region contains data for the given key.

from Region
CacheEntry|null
get(CacheKey $key)

Get an item from the cache.

from Region
put(CacheKey $key, CacheEntry $entry, Lock $lock = null)

Put an item into the cache.

from Region
evict(CacheKey $key)

Remove an item from the cache.

from Region
evictAll()

Remove all contents of this particular cache region.

from Region
lock(CacheKey $key)

Attempts to read lock the mapping for the given key.

void
unlock(CacheKey $key, Lock $lock)

Attempts to read unlock the mapping for the given key.

Details

CacheEntry[]|null getMultiple(CollectionCacheEntry $collection)

Get all items from the cache identified by $keys.

It returns NULL if some elements can not be found.

Parameters

CollectionCacheEntry $collection The collection of the items to be retrieved.

Return Value

CacheEntry[]|null The cached entries or NULL if one or more entries can not be found

string getName()

Retrieve the name of this region.

Return Value

string The region name

boolean contains(CacheKey $key)

Determine whether this region contains data for the given key.

Parameters

CacheKey $key The cache key

Return Value

boolean TRUE if the underlying cache contains corresponding data; FALSE otherwise.

CacheEntry|null get(CacheKey $key)

Get an item from the cache.

Parameters

CacheKey $key The key of the item to be retrieved.

Return Value

CacheEntry|null The cached entry or NULL

Exceptions

CacheException Indicates a problem accessing the item or region.

put(CacheKey $key, CacheEntry $entry, Lock $lock = null)

Put an item into the cache.

Parameters

CacheKey $key The key under which to cache the item.
CacheEntry $entry The entry to cache.
Lock $lock The lock previously obtained.

Exceptions

CacheException Indicates a problem accessing the region.

evict(CacheKey $key)

Remove an item from the cache.

Parameters

CacheKey $key The key under which to cache the item.

Exceptions

CacheException Indicates a problem accessing the region.

evictAll()

Remove all contents of this particular cache region.

Exceptions

CacheException Indicates problem accessing the region.

Lock lock(CacheKey $key)

Attempts to read lock the mapping for the given key.

Parameters

CacheKey $key The key of the item to lock.

Return Value

Lock A lock instance or NULL if the lock already exists.

Exceptions

LockException Indicates a problem accessing the region.

void unlock(CacheKey $key, Lock $lock)

Attempts to read unlock the mapping for the given key.

Parameters

CacheKey $key The key of the item to unlock.
Lock $lock The lock previously obtained from {@link readLock}

Return Value

void

Exceptions

LockException Indicates a problem accessing the region.