Package com.alachisoft.ncache.client
Interface Cache
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.util.Enumeration
public interface Cache extends java.util.Enumeration, java.lang.AutoCloseable
This interface contians the services and methods that are used to perform operations on the cache.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CacheItemVersion
add(java.lang.String key, CacheItem item)
Adds aCacheItem
to the cache.CacheItemVersion
add(java.lang.String key, CacheItem item, WriteThruOptions writeThruOptions)
Adds aCacheItem
to the cache.CacheItemVersion
add(java.lang.String key, java.lang.Object value)
Adds an item into the Cache object with a cache key to reference its location.java.util.concurrent.FutureTask<CacheItemVersion>
addAsync(java.lang.String key, CacheItem item)
Adds aCacheItem
to the cache asynchronously with a cache key to reference its location.java.util.concurrent.FutureTask<CacheItemVersion>
addAsync(java.lang.String key, CacheItem item, WriteThruOptions writeThruOptions)
Adds aCacheItem
to the cache asynchronously with a cache key to reference its location and WriteThruOptions.java.util.concurrent.FutureTask<CacheItemVersion>
addAsync(java.lang.String key, java.lang.Object value)
Adds an object into the cache asynchronously with a cache key to reference its location.java.util.Map<java.lang.String,java.lang.Exception>
addBulk(java.util.Map<java.lang.String,CacheItem> items)
Adds a Map of cache keys withCacheItem
to the cache.java.util.Map<java.lang.String,java.lang.Exception>
addBulk(java.util.Map<java.lang.String,CacheItem> items, WriteThruOptions writeThruOptions)
Adds a Map of cache keys withCacheItem
to the cache with the WriteThruOptions.java.util.Iterator
asJsonIterator()
Retrieves a Map iterator used to iterate through the key settings and their values as JSON objects contained in the cache.void
clear()
Removes all elements from theCache
.void
clearClientCache()
Removes all elements from the client cache.boolean
contains(java.lang.String key)
Determines whether the cache contains a specific key.java.util.Map<java.lang.String,java.lang.Boolean>
containsBulk(java.lang.Iterable<java.lang.String> keys)
Determines whether the cache contains specifiec keys.void
delete(java.lang.String key)
Deletes the item with the specified key from cache.void
delete(java.lang.String key, LockHandle lockHandle, CacheItemVersion version, WriteThruOptions writeThruOptions)
Deletes the specified item from theCache
.void
delete(java.lang.String key, WriteThruOptions writeThruOptions)
Deletes the specified item from theCache
.java.util.concurrent.FutureTask
deleteAsync(java.lang.String key)
Deletes an item from the cache asynchronously with a cache key to reference its location.java.util.concurrent.FutureTask
deleteAsync(java.lang.String key, WriteThruOptions writeThruOptions)
Deletes an item from the cache asynchronously with a cache key to reference its location.void
deleteBulk(java.lang.Iterable<java.lang.String> keys)
Deletes the specified items from theCache
.void
deleteBulk(java.lang.Iterable<java.lang.String> keys, WriteThruOptions writeThruOptions)
Deletes the specified items from theCache
.<T> T
get(java.lang.String key, boolean acquireLock, TimeSpan lockTimeout, LockHandle lockHandle, java.lang.Class<?> cls)
Retrieves the specified item from the Cache if it is not already locked.<T> T
get(java.lang.String key, CacheItemVersion version, ReadThruOptions readThruOptions, java.lang.Class<?> cls)
Retrieves the specified item from the cache, with read-through caching option available.If the option of read-through has been set, the object will be fetched from the data source if it does not exist in cache.<T> T
get(java.lang.String key, ReadThruOptions readThruOptions, java.lang.Class<?> cls)
Retrieves the specified item from the Cache object, with read-through caching option available.<T> T
get(java.lang.String key, java.lang.Class<?> cls)
Retrieves the specified item from the Cache object.<T> java.util.Map<java.lang.String,T>
getBulk(java.lang.Iterable<java.lang.String> keys, ReadThruOptions readThruOptions, java.lang.Class<?> cls)
Retrieves the objects from cache for the given keys as key-value pairs in form of a Map.<T> java.util.Map<java.lang.String,T>
getBulk(java.lang.Iterable<java.lang.String> keys, java.lang.Class<?> cls)
Retrieves the objects from cache for the given keys as key-value pairs in form of a Map.CacheItem
getCacheItem(java.lang.String key)
Retrieves the specified CacheItem from the cache.CacheItem
getCacheItem(java.lang.String key, boolean acquireLock, TimeSpan lockTimeout, LockHandle lockHandle)
Get the cache item stored in cache.CacheItem
getCacheItem(java.lang.String key, CacheItemVersion version, ReadThruOptions readThruOptions)
Retrieves the specified CacheItem from the cache.This method also allows specifying the read-through option.CacheItem
getCacheItem(java.lang.String key, ReadThruOptions readThruOptions)
Retrieves the specified CacheItem from the cache.java.util.Map<java.lang.String,CacheItem>
getCacheItemBulk(java.lang.Iterable<java.lang.String> keys)
Retrieves the specified CacheItems from the cache objectjava.util.Map<java.lang.String,CacheItem>
getCacheItemBulk(java.lang.Iterable<java.lang.String> keys, ReadThruOptions readThruOptions)
Retrieves the specified cacheItems from the cache.CacheStream
getCacheStream(java.lang.String key, CacheStreamAttributes cacheStreamAttributes)
Gets an instance ofCacheStream
ClientInfo
getClientInfo()
Displays the information related to this client.java.util.List<ClientInfo>
getConnectedClientList()
Gets the information of all connected clients to the cache.long
getCount()
Gets the number of items stored in the cache.DataStructureManager
getDataStructuresManager()
Gets an instance ofDataStructureManager
.<T> T
getIfNewer(java.lang.String key, CacheItemVersion version, java.lang.Class<?> cls)
Gets an object from the cache only if a newer version of the object exists in cache.MessagingService
getMessagingService()
Gets an instance ofMessagingService
NotificationService
getNotificationService()
Gets an instance ofNotificationService
.SearchService
getSearchService()
Gets an instance ofSearchService
.CacheItemVersion
insert(java.lang.String key, CacheItem item)
Inserts aCacheItem
to the cache.CacheItemVersion
insert(java.lang.String key, CacheItem item, WriteThruOptions writeThruOptions)
Inserts aCacheItem
to the cache, allowing to specify the Write-Through options.CacheItemVersion
insert(java.lang.String key, CacheItem item, WriteThruOptions writeThruOptions, LockHandle lockHandle, boolean releaseLock)
Inserts aCacheItem
to the cache, allowing to specify the Write-Through options.CacheItemVersion
insert(java.lang.String key, java.lang.Object value)
Inserts an item (object) into the cache.java.util.concurrent.FutureTask<CacheItemVersion>
insertAsync(java.lang.String key, CacheItem item)
Inserts aCacheItem
to the cache asynchronously with a cache key to reference its location.java.util.concurrent.FutureTask<CacheItemVersion>
insertAsync(java.lang.String key, CacheItem item, WriteThruOptions writeThruOptions)
Inserts aCacheItem
to the cache asynchronously with a cache key to reference its location and WriteThruOptions.java.util.concurrent.FutureTask<CacheItemVersion>
insertAsync(java.lang.String key, java.lang.Object value)
Inserts an object into the cache asynchronously with a cache key to reference its location.java.util.Map<java.lang.String,java.lang.Exception>
insertBulk(java.util.Map<java.lang.String,CacheItem> items)
Inserts a Map of cache keys withCacheItem
to the cache.java.util.Map<java.lang.String,java.lang.Exception>
insertBulk(java.util.Map<java.lang.String,CacheItem> items, WriteThruOptions writeThruOptions)
Inserts a Map of cache keys withCacheItem
to the cache with the WriteThruOptions.boolean
lock(java.lang.String key, TimeSpan lockTimeout, LockHandle lockHandle)
Acquires a lock on an item in the cache.<T> T
remove(java.lang.String key, LockHandle lockHandle, CacheItemVersion version, WriteThruOptions writeThruOptions, java.lang.Class<?> cls)
Removes and retrieves the specified item from theCache
.<T> T
remove(java.lang.String key, WriteThruOptions writeThruOptions, java.lang.Class<?> cls)
Removes and retrieves the specified item from theCache
.<T> T
remove(java.lang.String key, java.lang.Class<?> cls)
Removes and retrieves the item with the specified key from cache.<T> java.util.concurrent.FutureTask<T>
removeAsync(java.lang.String key, WriteThruOptions writeThruOptions, java.lang.Class<?> cls)
Removes an item from the cache asynchronously with a cache key to reference its location.<T> java.util.concurrent.FutureTask<T>
removeAsync(java.lang.String key, java.lang.Class<?> cls)
Removes an item from the cache asynchronously with a cache key to reference its location.<T> java.util.Map<java.lang.String,T>
removeBulk(java.lang.Iterable<java.lang.String> keys, WriteThruOptions writeThruOptions, java.lang.Class<?> cls)
Removes the specified items from theCache
and returns them to the application in the form of a Map.<T> java.util.Map<java.lang.String,T>
removeBulk(java.lang.Iterable<java.lang.String> keys, java.lang.Class<?> cls)
Removes the specified items from theCache
and returns them to the application in the form of a Map.void
unlock(java.lang.String key)
Forcefully unlocks a locked cached item.void
unlock(java.lang.String key, LockHandle lockHandle)
Unlocks a locked cached item if the correct LockHandle is specified.boolean
updateAttributes(java.lang.String key, CacheItemAttributes attributes)
UpdateCacheItemAttributes
of an existing item in cache.
-
-
-
Method Detail
-
getCount
long getCount() throws CacheException
Gets the number of items stored in the cache.- Returns:
- The number of items stored in the cache.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.
-
getClientInfo
ClientInfo getClientInfo() throws CacheException
Displays the information related to this client.- Returns:
- The information related to this client.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.
-
getConnectedClientList
java.util.List<ClientInfo> getConnectedClientList() throws CacheException
Gets the information of all connected clients to the cache.- Returns:
- A list that contains information of all client connected to the cache.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.
-
getMessagingService
MessagingService getMessagingService() throws CacheException
Gets an instance ofMessagingService
- Returns:
- An instance of
MessagingService
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.
-
getSearchService
SearchService getSearchService() throws CacheException
Gets an instance ofSearchService
.- Returns:
- An instance of
SearchService
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.
-
getNotificationService
NotificationService getNotificationService() throws CacheException
Gets an instance ofNotificationService
.- Returns:
- An instance of
NotificationService
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.
-
getDataStructuresManager
DataStructureManager getDataStructuresManager() throws CacheException
Gets an instance ofDataStructureManager
.- Returns:
- An instance of
DataStructureManager
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.
-
add
CacheItemVersion add(java.lang.String key, java.lang.Object value) throws CacheException, java.lang.IllegalArgumentException
Adds an item into the Cache object with a cache key to reference its location.- Parameters:
key
- Unique key to identify the cache item.value
- The item (object) to be stored in the cache.- Returns:
- Represents the version of each cache item.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
add
CacheItemVersion add(java.lang.String key, CacheItem item) throws CacheException, java.lang.IllegalArgumentException
Adds aCacheItem
to the cache. Using CacheItem, you can also specify properties for the cache items, for e.g., expiration and priority.- Parameters:
key
- Unique key to identify the cache item.item
-CacheItem
that is to be stored in the cache.- Returns:
- Represents the version of each cache item.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
add
CacheItemVersion add(java.lang.String key, CacheItem item, WriteThruOptions writeThruOptions) throws CacheException, java.lang.IllegalArgumentException
Adds aCacheItem
to the cache. It also lets you specify the WriteThruOptions. Using CacheItem, you can also specify properties for the cache items, for e.g., expiration and priority.- Parameters:
key
- Unique key to identify the cache item.item
-CacheItem
that is to be stored in the cache.writeThruOptions
-WriteThruOptions
regarding updating the data source. This can be either WriteThru, WriteBehind or None.- Returns:
- Represents the version of each cache item.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
addBulk
java.util.Map<java.lang.String,java.lang.Exception> addBulk(java.util.Map<java.lang.String,CacheItem> items) throws CacheException, java.lang.IllegalArgumentException
Adds a Map of cache keys withCacheItem
to the cache. The CacheItem contains properties to associate with the item, like expiration, dependencies and eviction information.- Parameters:
items
-Map
of keys andCacheItem
. Keys must be unique.- Returns:
Map
of Keys along with Exception that were unable to store in cache.- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
addBulk
java.util.Map<java.lang.String,java.lang.Exception> addBulk(java.util.Map<java.lang.String,CacheItem> items, WriteThruOptions writeThruOptions) throws CacheException, java.lang.IllegalArgumentException
Adds a Map of cache keys withCacheItem
to the cache with the WriteThruOptions. The CacheItem contains properties to associate with the item, like expiration, dependencies and eviction information.- Parameters:
items
-Map
of keys andCacheItem
. Keys must be unique.writeThruOptions
-WriteThruOptions
regarding updating the data source. This can be either WriteThru, WriteBehind or None.- Returns:
Map
of Keys along with Exception that were unable to store in cache.- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
addAsync
java.util.concurrent.FutureTask<CacheItemVersion> addAsync(java.lang.String key, java.lang.Object value) throws CacheException, java.lang.IllegalArgumentException
Adds an object into the cache asynchronously with a cache key to reference its location.- Parameters:
key
- Unique key to identify the cache item.value
- The item (object) to be stored in the cache.- Returns:
- Future Task that performs an add operation in the background. Once completed returns version of
cache item that was added in cache. Methods of
FutureTask
can be used to determine status of the task i.e. isDone(), isCancelled(). - Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
addAsync
java.util.concurrent.FutureTask<CacheItemVersion> addAsync(java.lang.String key, CacheItem item) throws CacheException, java.lang.IllegalArgumentException
Adds aCacheItem
to the cache asynchronously with a cache key to reference its location.- Parameters:
key
- Unique key to identify the cache item.item
-CacheItem
that is to be stored in the cache.- Returns:
- Future Task that performs an add operation in the background. Once completed returns version of
cache item that was added in cache. Methods of
FutureTask
can be used to determine status of the task i.e. isDone(), isCancelled(). - Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
addAsync
java.util.concurrent.FutureTask<CacheItemVersion> addAsync(java.lang.String key, CacheItem item, WriteThruOptions writeThruOptions) throws CacheException, java.lang.IllegalArgumentException
Adds aCacheItem
to the cache asynchronously with a cache key to reference its location and WriteThruOptions.- Parameters:
key
- Unique key to identify the cache item.item
-CacheItem
that is to be stored in the cache.writeThruOptions
-WriteThruOptions
regarding updating the data source. This can be either WriteThru, WriteBehind or None.- Returns:
- Future Task that performs an add operation in the background. Once completed returns version of
cache item that was added in cache. Methods of
FutureTask
can be used to determine status of the task i.e. isDone(), isCancelled(). - Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
insert
CacheItemVersion insert(java.lang.String key, java.lang.Object value) throws CacheException, java.lang.IllegalArgumentException
Inserts an item (object) into the cache.- Parameters:
key
- Unique key to identify the cache item.value
- The item (object) that is to be inserted into the cache.- Returns:
- Represents the version of each cache item.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
insert
CacheItemVersion insert(java.lang.String key, CacheItem item) throws CacheException, java.lang.IllegalArgumentException
Inserts aCacheItem
to the cache.- Parameters:
key
- Unique key to identify the cache item.item
- The CacheItem that is to be inserted into the cache.- Returns:
- Represents the version of each cache item.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
insert
CacheItemVersion insert(java.lang.String key, CacheItem item, WriteThruOptions writeThruOptions) throws CacheException, java.lang.IllegalArgumentException
Inserts aCacheItem
to the cache, allowing to specify the Write-Through options.- Parameters:
key
- Unique key to identify the cache item.item
- The CacheItem that is to be inserted into the cache.writeThruOptions
-WriteThruOptions
regarding updating the data source. This can be either WriteThru, WriteBehind or None.- Returns:
- Represents the version of each cache item.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
insert
CacheItemVersion insert(java.lang.String key, CacheItem item, WriteThruOptions writeThruOptions, LockHandle lockHandle, boolean releaseLock) throws CacheException, java.lang.IllegalArgumentException
Inserts aCacheItem
to the cache, allowing to specify the Write-Through options.- Parameters:
key
- Unique key to identify the cache item.item
- The CacheItem that is to be inserted into the cache.writeThruOptions
-WriteThruOptions
regarding updating the data source. This can be either WriteThru, WriteBehind or None.lockHandle
- An instance ofLockHandle
that holds the lock information. If the item is locked, then it can only be updated if the correct lockHandle is specified.releaseLock
- A flag to determine whether or not the lock should be released after operation is performed.- Returns:
- Represents the version of each cache item.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
insertBulk
java.util.Map<java.lang.String,java.lang.Exception> insertBulk(java.util.Map<java.lang.String,CacheItem> items) throws CacheException, java.lang.IllegalArgumentException
Inserts a Map of cache keys withCacheItem
to the cache. The CacheItem contains properties to associate with the item, like expiration, dependencies and eviction information.- Parameters:
items
-Map
of keys andCacheItem
. Keys must be unique.- Returns:
Map
of Keys along with Exception that were unable to store in cache.- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
insertBulk
java.util.Map<java.lang.String,java.lang.Exception> insertBulk(java.util.Map<java.lang.String,CacheItem> items, WriteThruOptions writeThruOptions) throws CacheException, java.lang.IllegalArgumentException
Inserts a Map of cache keys withCacheItem
to the cache with the WriteThruOptions. The CacheItem contains properties to associate with the item, like expiration, dependencies and eviction information.- Parameters:
items
-Map
of keys andCacheItem
. Keys must be unique.writeThruOptions
-WriteThruOptions
regarding updating the data source. This can be either WriteThru, WriteBehind or None.- Returns:
Map
of Keys along with Exception that were unable to store in cache.- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
insertAsync
java.util.concurrent.FutureTask<CacheItemVersion> insertAsync(java.lang.String key, java.lang.Object value) throws CacheException, java.lang.IllegalArgumentException
Inserts an object into the cache asynchronously with a cache key to reference its location.- Parameters:
key
- Unique key to identify the cache item.value
- The item (object) to be stored in the cache.- Returns:
- Future Task that performs an insert operation in the background. Once completed returns version of
cache item that was added in cache. Methods of
FutureTask
can be used to determine status of the task i.e. isDone(), isCancelled(). - Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
insertAsync
java.util.concurrent.FutureTask<CacheItemVersion> insertAsync(java.lang.String key, CacheItem item) throws CacheException, java.lang.IllegalArgumentException
Inserts aCacheItem
to the cache asynchronously with a cache key to reference its location.- Parameters:
key
- Unique key to identify the cache item.item
-CacheItem
that is to be stored in the cache.- Returns:
- Future Task that performs an insert operation in the background. Once completed returns version of
cache item that was added in cache. Methods of
FutureTask
can be used to determine status of the task i.e. isDone(), isCancelled(). - Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
insertAsync
java.util.concurrent.FutureTask<CacheItemVersion> insertAsync(java.lang.String key, CacheItem item, WriteThruOptions writeThruOptions) throws CacheException, java.lang.IllegalArgumentException
Inserts aCacheItem
to the cache asynchronously with a cache key to reference its location and WriteThruOptions.- Parameters:
key
- Unique key to identify the cache item.item
-CacheItem
that is to be stored in the cache.writeThruOptions
-WriteThruOptions
regarding updating the data source. This can be either WriteThru, WriteBehind or None.- Returns:
- Future Task that performs an insert operation in the background. Once completed returns version of
cache item that was added in cache. Methods of
FutureTask
can be used to determine status of the task i.e. isDone(), isCancelled(). - Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
updateAttributes
boolean updateAttributes(java.lang.String key, CacheItemAttributes attributes) throws CacheException, java.lang.IllegalArgumentException
UpdateCacheItemAttributes
of an existing item in cache.- Parameters:
key
- Unique key to identify the cache item.attributes
- An instance ofCacheItemAttributes
to update item in the cache.- Returns:
- Flag that determines status of the update operation. True if attributes of the item in cache was updated successfully otherwise False .
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
get
<T> T get(java.lang.String key, java.lang.Class<?> cls) throws CacheException, java.lang.IllegalArgumentException, java.lang.ClassCastException
Retrieves the specified item from the Cache object.- Type Parameters:
T
- Specifies the type of value obtained from the cache.- Parameters:
key
- The unique identifier for the cache item to be retrieved.cls
- Specifies the class of value obtained from the cache.- Returns:
- The retrieved cache item, or a null reference if the key is not found.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
java.lang.ClassCastException
- If the object returned form cache is not an instance of the specified class or any of its subclass/subclasses.
-
get
<T> T get(java.lang.String key, ReadThruOptions readThruOptions, java.lang.Class<?> cls) throws CacheException, java.lang.IllegalArgumentException, java.lang.ClassCastException
Retrieves the specified item from the Cache object, with read-through caching option available. If the option of read-through has been set, the object will be fetched from the data source if it does not exist in cache.- Type Parameters:
T
- Specifies the type of value obtained from the cache.- Parameters:
key
- The unique identifier for the cache item to be retrieved.readThruOptions
-ReadThruOptions
to read from data source. These can be either ReadThru, ReadThruForced or None.cls
- Specifies the class of value obtained from the cache.- Returns:
- The retrieved cache item, or a null reference if the key is not found.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
java.lang.ClassCastException
- If the object returned form cache is not an instance of the specified class or any of its subclass/subclasses.
-
get
<T> T get(java.lang.String key, boolean acquireLock, TimeSpan lockTimeout, LockHandle lockHandle, java.lang.Class<?> cls) throws CacheException, java.lang.IllegalArgumentException, java.lang.ClassCastException
Retrieves the specified item from the Cache if it is not already locked. Otherwise it returns null.This is different from the basic Get operation where an item is returned ignoring the lock altogether.- Type Parameters:
T
- Specifies the type of value obtained from the cache.- Parameters:
key
- Unique identifier for the cache item to be retrieved.acquireLock
- A flag to determine whether to acquire a lock or not.lockTimeout
- The TimeSpan after which the lock is automatically released.lockHandle
- An instance ofLockHandle
to hold the lock information.cls
- Specifies the class of value obtained from the cache.- Returns:
- The retrieved cache item, or a null reference if the key is not found.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
java.lang.ClassCastException
- If the object returned form cache is not an instance of the specified class or any of its subclass/subclasses.
-
get
<T> T get(java.lang.String key, CacheItemVersion version, ReadThruOptions readThruOptions, java.lang.Class<?> cls) throws CacheException, java.lang.IllegalArgumentException, java.lang.ClassCastException
Retrieves the specified item from the cache, with read-through caching option available.If the option of read-through has been set, the object will be fetched from the data source if it does not exist in cache.- Type Parameters:
T
- Specifies the type of value obtained from the cache.- Parameters:
key
- Unique identifier for the cache item to be retrieved.version
- The version of the object.readThruOptions
-ReadThruOptions
to read from data source. These can be either ReadThru, ReadThruForced or None.cls
- Specifies the class of value obtained from the cache.- Returns:
- The retrieved cache item, or a null reference if the key is not found.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
java.lang.ClassCastException
- If the object returned form cache is not an instance of the specified class or any of its subclass/subclasses.
-
getBulk
<T> java.util.Map<java.lang.String,T> getBulk(java.lang.Iterable<java.lang.String> keys, java.lang.Class<?> cls) throws CacheException, java.lang.IllegalArgumentException, java.lang.ClassCastException
Retrieves the objects from cache for the given keys as key-value pairs in form of a Map.- Type Parameters:
T
- Specifies the type of value obtained from the cache.- Parameters:
keys
- The keys against which items are to be fetched from cache.cls
- Specifies the class of value obtained from the cache.- Returns:
- The retrieved cache items as Map of key-value pairs.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
java.lang.ClassCastException
- If the object returned form cache is not an instance of the specified class or any of its subclass/subclasses.
-
getBulk
<T> java.util.Map<java.lang.String,T> getBulk(java.lang.Iterable<java.lang.String> keys, ReadThruOptions readThruOptions, java.lang.Class<?> cls) throws CacheException, java.lang.IllegalArgumentException, java.lang.ClassCastException
Retrieves the objects from cache for the given keys as key-value pairs in form of a Map.- Type Parameters:
T
- Specifies the type of value obtained from the cache.- Parameters:
keys
- The keys against which items are to be fetched from cache.readThruOptions
-ReadThruOptions
to read from data source. These can be either ReadThru, ReadThruForced or None.cls
- Specifies the class of value obtained from the cache.- Returns:
- The retrieved cache items as Map of key-value pairs.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
java.lang.ClassCastException
- If the object returned form cache is not an instance of the specified class or any of its subclass/subclasses.
-
getCacheItem
CacheItem getCacheItem(java.lang.String key) throws CacheException, java.lang.IllegalArgumentException
Retrieves the specified CacheItem from the cache.- Parameters:
key
- Unique identifier for the cache item to be retrieved.- Returns:
- The specified CacheItem. If the key does not exist, it returns null.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
getCacheItem
CacheItem getCacheItem(java.lang.String key, ReadThruOptions readThruOptions) throws CacheException, java.lang.IllegalArgumentException
Retrieves the specified CacheItem from the cache. This overload also allows specifying the read-through option. If read-through is set and the object does not exist in the cache,the object will be fetched from the data source and added to the cache.- Parameters:
key
- Unique identifier for the cache item to be retrieved.readThruOptions
-ReadThruOptions
regarding reading from data source. It can be either ReadThru, ReadThruForced or None.- Returns:
- The specified CacheItem. If the key does not exist, it returns null.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
getCacheItem
CacheItem getCacheItem(java.lang.String key, CacheItemVersion version, ReadThruOptions readThruOptions) throws CacheException, java.lang.IllegalArgumentException
Retrieves the specified CacheItem from the cache.This method also allows specifying the read-through option. if read-through is set and the object does not exist in the cache, the object will be fetched from the data source and added to the cache.- Parameters:
key
- Unique identifier for the cache item to be retrieved.version
- TheCacheItemVersion
of the object.readThruOptions
-ReadThruOptions
regarding reading from data source. It can be either ReadThru, ReadThruForced or None.- Returns:
- The specified CacheItem. If the key does not exist, it returns null.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
getCacheItem
CacheItem getCacheItem(java.lang.String key, boolean acquireLock, TimeSpan lockTimeout, LockHandle lockHandle) throws CacheException, java.lang.IllegalArgumentException
Get the cache item stored in cache. Loack handle can be given with this and a flag can be set if you want to acquire lock.- Parameters:
key
- Key used to reference the desired object.acquireLock
- A flag to determine whether to acquire a lock or not.lockTimeout
- The TimeSpan after which the lock is automatically released.lockHandle
- An instance ofLockHandle
to hold the lock information.- Returns:
- The retrieved cache item. If key is not found, returns null.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
getCacheItemBulk
java.util.Map<java.lang.String,CacheItem> getCacheItemBulk(java.lang.Iterable<java.lang.String> keys) throws CacheException, java.lang.IllegalArgumentException, java.lang.ClassCastException
Retrieves the specified CacheItems from the cache object- Parameters:
keys
-Iterable
list of unique identifiers for the cache items to be retrieved.- Returns:
- The retrieved cache items as key-value pairs in a Map.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
java.lang.ClassCastException
- If the object returned form cache is not an instance of the specified class or any of its subclass/subclasses.
-
getCacheItemBulk
java.util.Map<java.lang.String,CacheItem> getCacheItemBulk(java.lang.Iterable<java.lang.String> keys, ReadThruOptions readThruOptions) throws CacheException, java.lang.IllegalArgumentException, java.lang.ClassCastException
Retrieves the specified cacheItems from the cache. This overload also allows specifying the read-through option. If read-through is set and the object does not exist in the cache,the object will be fetched from the data source and added to the cache.- Parameters:
keys
-Iterable
list of unique identifiers for the cache items to be retrieved.readThruOptions
-ReadThruOptions
regarding reading from data source. It can be either ReadThru, ReadThruForced or None.- Returns:
- The retrieved cache items as a Map of key-value pairs.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
java.lang.ClassCastException
- If the object returned form cache is not an instance of the specified class or any of its subclass/subclasses.
-
getIfNewer
<T> T getIfNewer(java.lang.String key, CacheItemVersion version, java.lang.Class<?> cls) throws CacheException
Gets an object from the cache only if a newer version of the object exists in cache.- Type Parameters:
T
- Specifies the type of value obtained from the cache.- Parameters:
key
- Unique key used to reference the desired object.version
- TheCacheItemVersion
of the object.cls
- Specifies the class of value obtained from the cache.- Returns:
- If a newer object exists in the cache, the object is returned. Otherwise, null is returned.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.
-
delete
void delete(java.lang.String key) throws CacheException, java.lang.IllegalArgumentException
Deletes the item with the specified key from cache.- Parameters:
key
- Unique key of the item to be deleted.- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
delete
void delete(java.lang.String key, WriteThruOptions writeThruOptions) throws CacheException, java.lang.IllegalArgumentException
Deletes the specified item from theCache
. You can also specify the write option such that the item may be removed from both cache and data source.- Parameters:
key
- Unique key of the item to be deleted.writeThruOptions
-WriteThruOptions
regarding updating the data source. This can be either WriteThru, WriteBehind or None.- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
delete
void delete(java.lang.String key, LockHandle lockHandle, CacheItemVersion version, WriteThruOptions writeThruOptions) throws CacheException, java.lang.IllegalArgumentException
Deletes the specified item from theCache
. You can also specify the write option such that the item may be removed from both cache and data source.- Parameters:
key
- Unique key of the item to be deleted.lockHandle
- If the item is locked, it can be removed only if the correct lockHandle is specified. lockHandle should be the same which was used initially to lock the item, otherwise you will get the 'OperationFailedException'.version
- The version of the item to be removed. The item is removed from the cache only if this is still the most recent version in the cache.writeThruOptions
-WriteThruOptions
regarding updating the data source. This can be either WriteThru, WriteBehind or None.- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
deleteAsync
java.util.concurrent.FutureTask deleteAsync(java.lang.String key) throws CacheException, java.lang.IllegalArgumentException
Deletes an item from the cache asynchronously with a cache key to reference its location.- Parameters:
key
- Unique key of the item to be deleted.- Returns:
- Future Task that performs an delete operation in the background.Methods of
FutureTask
can be used to determine status of the task i.e. isDone(), isCancelled(). - Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
deleteAsync
java.util.concurrent.FutureTask deleteAsync(java.lang.String key, WriteThruOptions writeThruOptions) throws CacheException, java.lang.IllegalArgumentException
Deletes an item from the cache asynchronously with a cache key to reference its location.- Parameters:
key
- key Unique key of the item to be deleted.writeThruOptions
-WriteThruOptions
regarding updating the data source. This can be either WriteThru, WriteBehind or None.- Returns:
- Future Task that performs an delete operation in the background. Methods of
FutureTask
can be used to determine status of the task i.e. isDone(), isCancelled(). - Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
deleteBulk
void deleteBulk(java.lang.Iterable<java.lang.String> keys) throws CacheException, java.lang.IllegalArgumentException, java.lang.ClassCastException
Deletes the specified items from theCache
.- Parameters:
keys
-Iterable
list of unique keys to reference the items.- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
java.lang.ClassCastException
-
deleteBulk
void deleteBulk(java.lang.Iterable<java.lang.String> keys, WriteThruOptions writeThruOptions) throws CacheException, java.lang.IllegalArgumentException, java.lang.ClassCastException
Deletes the specified items from theCache
. You can also specify the write option such that the items may be removed from both cache and data source.- Parameters:
keys
-Iterable
list of unique keys to reference the items.writeThruOptions
-WriteThruOptions
regarding updating the data source. This can be either WriteThru, WriteBehind or None.- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
java.lang.ClassCastException
-
remove
<T> T remove(java.lang.String key, java.lang.Class<?> cls) throws CacheException, java.lang.IllegalArgumentException, java.lang.ClassCastException
Removes and retrieves the item with the specified key from cache.- Type Parameters:
T
- Specifies the type of value obtained from the cache.- Parameters:
key
- Unique key of the item to be removed.cls
- Specifies the class of value obtained from the cache.- Returns:
- The removed item if the key exists otherwise null is returned.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
java.lang.ClassCastException
- If the object returned form cache is not an instance of the specified class or any of its subclass/subclasses.
-
remove
<T> T remove(java.lang.String key, WriteThruOptions writeThruOptions, java.lang.Class<?> cls) throws CacheException, java.lang.IllegalArgumentException, java.lang.ClassCastException
Removes and retrieves the specified item from theCache
. You can also specify the write option such that the item may be removed from both cache and data source.- Type Parameters:
T
- Specifies the type of value obtained from the cache.- Parameters:
key
- Unique key of the item to be removed.writeThruOptions
-WriteThruOptions
regarding updating the data source. This can be either WriteThru, WriteBehind or None.cls
- Specifies the class of value obtained from the cache.- Returns:
- The removed item if the key exists otherwise null is returned.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
java.lang.ClassCastException
- If the object returned form cache is not an instance of the specified class or any of its subclass/subclasses.
-
remove
<T> T remove(java.lang.String key, LockHandle lockHandle, CacheItemVersion version, WriteThruOptions writeThruOptions, java.lang.Class<?> cls) throws CacheException, java.lang.IllegalArgumentException, java.lang.ClassCastException
Removes and retrieves the specified item from theCache
. You can also specify the write option such that the item may be removed from both cache and data source.- Type Parameters:
T
- Specifies the type of value obtained from the cache.- Parameters:
key
- Unique key of the item to be removed.lockHandle
- If the item is locked, it can be removed only if the correct lockHandle is specified. lockHandle should be the same which was used initially to lock the item, otherwise you will get the 'OperationFailedException'.version
- The version of the item to be removed. The item is removed from the cache only if this is still the most recent version in the cache.writeThruOptions
-WriteThruOptions
regarding updating the data source. This can be either WriteThru, WriteBehind or None.cls
- Specifies the class of value obtained from the cache.- Returns:
- The removed item if the key exists otherwise null is returned.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
java.lang.ClassCastException
- If the object returned form cache is not an instance of the specified class or any of its subclass/subclasses.
-
removeBulk
<T> java.util.Map<java.lang.String,T> removeBulk(java.lang.Iterable<java.lang.String> keys, java.lang.Class<?> cls) throws CacheException, java.lang.IllegalArgumentException, java.lang.ClassCastException
Removes the specified items from theCache
and returns them to the application in the form of a Map.- Type Parameters:
T
- Specifies the type of value obtained from the cache.- Parameters:
keys
-Iterable
list of unique keys to reference the items.cls
- Specifies the class of value obtained from the cache.- Returns:
- The removed items from cache in form of a Map.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
java.lang.ClassCastException
- If the object returned form cache is not an instance of the specified class or any of its subclass/subclasses.
-
removeBulk
<T> java.util.Map<java.lang.String,T> removeBulk(java.lang.Iterable<java.lang.String> keys, WriteThruOptions writeThruOptions, java.lang.Class<?> cls) throws CacheException, java.lang.IllegalArgumentException, java.lang.ClassCastException
Removes the specified items from theCache
and returns them to the application in the form of a Map.- Type Parameters:
T
- Specifies the type of value obtained from the cache.- Parameters:
keys
-Iterable
list of unique keys to reference the items.writeThruOptions
-WriteThruOptions
regarding updating the data source. This can be either WriteThru, WriteBehind or None.cls
- Specifies the class of value obtained from the cache.- Returns:
- The removed items from cache in form of a Map.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
java.lang.ClassCastException
- If the object returned form cache is not an instance of the specified class or any of its subclass/subclasses.
-
removeAsync
<T> java.util.concurrent.FutureTask<T> removeAsync(java.lang.String key, java.lang.Class<?> cls) throws CacheException, java.lang.IllegalArgumentException, java.lang.ClassCastException
Removes an item from the cache asynchronously with a cache key to reference its location.- Type Parameters:
T
- Specifies the type of value obtained from the cache.- Parameters:
key
- Unique key of the item to be removed.cls
- Specifies the class of value obtained from the cache.- Returns:
- Future Task that performs an remove operation in the background. Once completed returns the removed
cache item that was added in cache. Methods of
FutureTask
can be used to determine status of the task i.e. isDone(), isCancelled(). - Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
java.lang.ClassCastException
- If the object returned form cache is not an instance of the specified class or any of its subclass/subclasses.
-
removeAsync
<T> java.util.concurrent.FutureTask<T> removeAsync(java.lang.String key, WriteThruOptions writeThruOptions, java.lang.Class<?> cls) throws CacheException, java.lang.IllegalArgumentException, java.lang.ClassCastException
Removes an item from the cache asynchronously with a cache key to reference its location.- Type Parameters:
T
- Specifies the type of value obtained from the cache.- Parameters:
key
- Unique key of the item to be removed.writeThruOptions
-WriteThruOptions
regarding updating the data source. This can be either WriteThru, WriteBehind or None.cls
- Specifies the class of value obtained from the cache.- Returns:
- Future Task that performs an remove operation in the background. Once completed returns the removed
cache item that was added in cache. Methods of
FutureTask
can be used to determine status of the task i.e. isDone(), isCancelled(). - Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
java.lang.ClassCastException
- If the object returned form cache is not an instance of the specified class or any of its subclass/subclasses.
-
contains
boolean contains(java.lang.String key) throws CacheException, java.lang.IllegalArgumentException
Determines whether the cache contains a specific key.- Parameters:
key
- The key to locate in the cache.- Returns:
- true if the
Cache
contains an element with the specified key; otherwise, false. - Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
containsBulk
java.util.Map<java.lang.String,java.lang.Boolean> containsBulk(java.lang.Iterable<java.lang.String> keys) throws CacheException
Determines whether the cache contains specifiec keys.- Parameters:
keys
-Iterable
collection of keys.- Returns:
- Map of Keys with flag to dertermine presence of each key in cache.true if the
Cache
contains an elementwith the specified key; otherwise, false. - Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.
-
clear
void clear() throws CacheException
Removes all elements from theCache
.- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.
-
clearClientCache
void clearClientCache() throws CacheException
Removes all elements from the client cache.- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.
-
unlock
void unlock(java.lang.String key) throws CacheException, java.lang.IllegalArgumentException
Forcefully unlocks a locked cached item.- Parameters:
key
- Key of the cached item to be unlocked.- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
unlock
void unlock(java.lang.String key, LockHandle lockHandle) throws CacheException, java.lang.IllegalArgumentException
Unlocks a locked cached item if the correct LockHandle is specified. If LockHandle is null Forcefully unlocks a locked cached item.- Parameters:
key
- Key of the cached item to be unlocked.lockHandle
- An instance ofLockHandle
that is generated when the lock is acquired.- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
lock
boolean lock(java.lang.String key, TimeSpan lockTimeout, LockHandle lockHandle) throws CacheException, java.lang.IllegalArgumentException
Acquires a lock on an item in the cache.- Parameters:
key
- key of cached item to be locked.lockTimeout
- An instance ofTimeSpan
after which the lock is automatically released.lockHandle
- An instance ofLockHandle
that will be filled in with the lock information if lock is acquired successfully.- Returns:
- Whether or not lock was acquired successfully.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
getCacheStream
CacheStream getCacheStream(java.lang.String key, CacheStreamAttributes cacheStreamAttributes) throws CacheException, java.lang.IllegalArgumentException
Gets an instance ofCacheStream
- Parameters:
key
- The key used to reference the stream.cacheStreamAttributes
- Instance ofCacheStreamAttributes
to set attributes of the stream.- Returns:
- An instance of CacheStream.
- Throws:
CacheException
- So you can catch this exception for all the exceptions thrown from within the NCache.java.lang.IllegalArgumentException
-
asJsonIterator
java.util.Iterator asJsonIterator()
Retrieves a Map iterator used to iterate through the key settings and their values as JSON objects contained in the cache.- Returns:
- An iterator to iterate through
Cache
as JSON objects.
-
-