Class Cache
Implements the clustered cache for an application
Inheritance
Namespace:
Assembly: Alachisoft.NCache.Web.dll
Syntax
public class Cache : IEnumerable, IDisposable
Remarks
One instance of this class is created per application domain, and it remains valid as long as the application domain remains active. This object is accessible through the Alachisoft.NCache.Web.Caching.NCache.Cache property of the NCache object.
Examples
To create an instance of Cache class you can use code as follows:
Cache cache = NCache.InitializeCache("myReplicatedCache");
Application[�CacheHandle�] = cache;
Name | Description |
---|---|
DefaultAbsolute | A read only field, used to set expiration for cache entry while adding data to cache. Item will be expired from the cache within DefaultAbsolute value + cache clean up interval. The value for this field is given from NCache Manager. Minimum value for DefaultAbsolute expiration is 5s. |
DefaultAbsoluteLonger | A read only field, used to set expiration for cache entry while adding data to cache. Item will be expired from the cache after DefaultAbsoluteLonger value + cache clean up interval. The value for this field is given from NCache Manager. Minimum value for DefaultAbsoluteLonger expiration is 5s. |
DefaultSliding | A read only field, used to set expiration for cache entry while adding data to cache. Item will be expired from the cache within DefaultSliding value + cache clean up interval, if there is no fetching of that particular item. The value for this field is given from NCache Manager. Minimum value for DefaultSliding expiration is 5s. |
DefaultSlidingLonger | A read only field, used to set expiration for cache entry while adding data to cache. Item will be expired from the cache within DefaultSlidingLonger value + cache clean up interval, if there is no fetching of that particular item. The value for this field is given from NCache Manager. Minimum value for DefaultSlidingLonger expiration is 5s. |
NoAbsoluteExpiration | Used in the |
NoLockExpiration | Used as the |
NoSlidingExpiration | Used as the |
Name | Description |
---|---|
ClientInfo | Displays the information related to this client |
Count | Gets the number of items stored in the cache. |
ExceptionsEnabled | Flag that indicates whether exceptions are enabled or not. |
Item[String] | Gets or sets the cache item at the specified key. |
MessagingService | Instance of MessagingService. |
Name | Description |
---|---|
Add(String, CacheItem) | Add a CacheItem to the cache |
Add(String, CacheItem, DSWriteOption, DataSourceItemsAddedCallback) | Add a CacheItem to the cache. Also lets you set DSWriteOption and specify callback that triggers whenever an item is added in the data source. |
Add(String, CacheItem, DSWriteOption, String, DataSourceItemsAddedCallback) | Add a CacheItem to the cache. You can specify the DSWriteOption along with the data source provider name. Callback can also be registered that will be triggered every time an item is added in data source. |
Add(String, Object) | Adds an item into the Cache object with a cache key to reference its location and using default values provided by the CacheItemPriority enumeration. |
Add(String, Object, NamedTagsDictionary) | Adds an item into the Cache object with a cache key to reference its location and using default values provided by the CacheItemPriority enumeration. It also enables associating named tags with the object. |
Add(String, Object, Tag[]) | Adds an item into the Cache object with a cache key to reference its location and using default values provided by the CacheItemPriority enumeration. It also enables the associating tags with the object. |
Add(String, Object, CacheDependency, DateTime, TimeSpan, CacheItemPriority) | When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this parameter contains a null reference (Nothing in Visual Basic). |
Add(String, Object, DateTime, TimeSpan, CacheItemPriority) | Adds an object in cache having some expiration or priority. |
Add(String, Object, String, String) | Adds a value to the cache |
AddAsync(String, CacheItem, DSWriteOption, DataSourceItemsAddedCallback) | Add a CacheItem to the cache asynchronously. Option regarding data updating along with a delegate for notifying if an item is added in data source can be specified as well. |
AddAsync(String, CacheItem, DSWriteOption, String, DataSourceItemsAddedCallback) | Add a CacheItem to the cache asynchronously. The data source provider name, option regarding data updating and a delegate for notifying if an item is added in data source can be specified as well. |
AddAsync(String, Object, AsyncItemAddedCallback, String, String) | Add the object to the cache asynchronously. You can specify groups and subgroups using this API overload. A delegate can be specified for notifying you about the status of the operation. |
AddBulk(String[], CacheItem[]) | Add array of CacheItem to the cache. |
AddBulk(String[], CacheItem[], DSWriteOption, DataSourceItemsAddedCallback) | Add array of CacheItem to the cache.Also lets you specify DSWriteOption. It enables you to register a callback for notification when an item is added in data source. |
AddBulk(String[], CacheItem[], DSWriteOption, String, DataSourceItemsAddedCallback) | Add array of CacheItem to the cache. The data source provider name can be specified along with the option regarding data updating. A delegate that, if provided, is called when item is added to data source |
AddDependency(String, CacheDependency, Boolean) | Add dependency to the cache item. |
AddDependency(String, CacheSyncDependency) | Add CacheSyncDependency to the cache item. |
Aggregate(IValueExtractor, IAggregator) | Built upon MapReduce framework, processes distributed data records to return compiled and statistical results for analytical purposes. |
Aggregate(IValueExtractor, IAggregator, IKeyFilter) | Built upon MapReduce framework, processes distributed data records to return compiled and statistical results for analytical purposes. You can specify key filters with this as well. |
Aggregate(IValueExtractor, IAggregator, IKeyFilter, Int32) | Built upon MapReduce framework, processes distributed data records to return compiled and statistical results for analytical purposes. You can specify key filter as well as time out. |
Aggregate(IValueExtractor, IAggregator, Int32) | It is built on MapReduce framework. It processes distributed data records to return compiled and statistical results for analytical purposes. Time out can also be specified. After that specified time, time out exception will be thrown and thread will be terminated. |
Aggregate(IValueExtractor, IAggregator, String, Hashtable) | Built upon MapReduce framework, processes distributed data records to return compiled and statistical results for analytical purposes. Queries and parameters can be specified with this. |
Aggregate(IValueExtractor, IAggregator, String, Hashtable, Int32) | Built upon MapReduce framework, processes distributed data records to return compiled and statistical results for analytical purposes. Queries, parameters and time out can be specified as well. |
Clear() | Removes all elements from the Cache. |
Clear(DSWriteOption, DataSourceClearedCallback) | Removes all elements from the Cache. (Obsolete Method) |
ClearAsync(AsyncCacheClearedCallback) | Removes all elements from the Cache asynchronously. |
ClearAsync(DSWriteOption, AsyncCacheClearedCallback, DataSourceClearedCallback) | Removes all elements from the Cache asynchronously. |
ClearClientCache() | Removes all elements from the client cache. |
ClearClientCacheAsync(AsyncCacheClearedCallback) | Clears client cache asynchronously. |
Contains(String) | Determines whether the cache contains a specific key. |
Delete(String) | Removes the object from the Cache. |
Delete(String, DSWriteOption, DataSourceItemsRemovedCallback) | Removes the object from the Cache. |
Delete(String, DSWriteOption, String, DataSourceItemsRemovedCallback) | Removes the object from the Cache. |
Delete(String, CacheItemVersion) | Removes an item from cache if the specified version is still the most recent version in the cache. |
Delete(String, LockHandle) | Removes an item from cache if it is not already locked or if the correct lock-id is specified. |
DeleteBulk(String[]) | Removes the objects from the Cache. |
DeleteBulk(String[], DSWriteOption, DataSourceItemsRemovedCallback) | Removes bulk objects from the Cache. |
DeleteBulk(String[], DSWriteOption, String, DataSourceItemsRemovedCallback) | Removes the objects from the Cache. |
Dispose() | Decerements the reference count of the cache and performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. |
ExecuteNonQuery(String, IDictionary) | Executes delete statements on Cache. |
ExecuteReader(String, IDictionary) | Performs search on the Cache based on the query specified. |
ExecuteReader(String, IDictionary, Boolean) | Performs search on the Cache based on the query specified. Also getData flag can be set that specifies if you want to receive values with keys. |
ExecuteReader(String, IDictionary, Boolean, Int32) | Performs search on the Cache based on the query specified. Also you can specify the chunkSize and flag for specifying if you want data with keys. |
ExecuteReaderCQ(ContinuousQuery) | Opens ExecuteReader(String, IDictionary, Boolean, Int32) on server nodes to execute query, also registers continuous query call backs for data, that falls on query's criteria; if any changes occur in that data. |
ExecuteReaderCQ(ContinuousQuery, Boolean) | Opens ExecuteReader(String, IDictionary, Boolean, Int32) on server nodes to execute query, also registers continuous query call backs for data, that falls on query's criteria; if any changes occur in that data.Falg for getting data can be set. |
ExecuteReaderCQ(ContinuousQuery, Boolean, Int32) | Opens ExecuteReader(String, IDictionary, Boolean, Int32) on server nodes to execute query, also registers |
ExecuteTask(MapReduceTask) | Executes the MapReduce task on the cache. |
ExecuteTask(MapReduceTask, IKeyFilter) | Executes the MapReduce task on the cache using specified KeyFilter implementation. |
ExecuteTask(MapReduceTask, String, Hashtable) | Executes the MapReduce task on the resultant items with specified query. |
Finalize() | Finalizer for this object. |
Get(String) | Retrieves the specified item from the Cache object. |
Get(String, DSReadOption) | Retrieves the specified item from the Cache object. If not available in cache gets from the datasource. |
Get(String, DSReadOption, ref CacheItemVersion) | Retrieves the specified item from the Cache object. If the object is read through the data source,
put it in the cache. It accepts the |
Get(String, ref CacheItemVersion) | Retrieves the specified item from the Cache object. It accepts the |
Get(String, String, DSReadOption) | Retrieves the specified item from the Cache object. |
Get(String, String, DSReadOption, ref CacheItemVersion) | Retrieves the specified item from the Cache object. If the object is read through the data source,
put it in the cache. It accepts the |
Get(String, String, String, DSReadOption) | Retrieves the specified item from the Cache object. If the object is read through the data source, put it against the given group and sub group. |
Get(String, TimeSpan, ref LockHandle, Boolean) | Retrieves the specified item from the Cache object if it is not already locked. Otherwise returns null (Nothing in Visual Basic). This is different from the normal Get operation where an item is returned ignoring the lock altogether. |
GetBulk(String[]) | Retrieves the object from the cache for the given keys as key value pairs |
GetBulk(String[], DSReadOption) | Retrieves the object from the cache for the given keys as key value pairs. Options regarding reading from data source can be set. |
GetBulk(String[], String, DSReadOption) | Retrieves the object from the cache for the given keys as key value pairs. Data source provider name can be specified for read through operation and options for reading from data source can be specified. |
GetByAllTags(Tag[]) | Returns the cached objects that have all the same tags in common. (Returns the Intersection set.) |
GetByAnyTag(Tag[]) | Returns the cached objects that have any of the same tags in common. (Returns the Union set.) |
GetByTag(Tag) | Gets all the cached objects with the specified tag. |
GetByTag(String) | Gets all the cached objects with the specified tag. |
GetCacheItem(String) | Get the cache item stored in cache. |
GetCacheItem(String, DSReadOption) | Retrieves the specified item from the Cache object. |
GetCacheItem(String, DSReadOption, ref CacheItemVersion) | Retrieves the specified item from the Cache object. If the object is read through the data source,
put it in the cache. It accepts the |
GetCacheItem(String, ref CacheItemVersion) | Retrieves the specified item from the Cache object. It accepts the |
GetCacheItem(String, String, DSReadOption) | Retrieves the specified item from the Cache object. |
GetCacheItem(String, String, DSReadOption, ref CacheItemVersion) | Retrieves the specified item from the Cache object. If the object is read through the data source,
put it in the cache. It accepts the |
GetCacheItem(String, String, String) | Get the cache item stored in cache according to the specified group and subgroup. |
GetCacheItem(String, String, String, DSReadOption) | Retrieves the specified item from the Cache object. If the object is read through the data source, put it against the given group and sub group. |
GetCacheItem(String, TimeSpan, ref LockHandle, Boolean) | 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. |
GetCacheStream(String, StreamMode) | Gets an instance of the CacheStream class. |
GetCacheStream(String, StreamMode, CacheItemPriority) | Gets an instance of the CacheStream class. You can specify the cache item priority as well. |
GetCacheStream(String, StreamMode, DateTime, TimeSpan, CacheItemPriority) | Gets an instance of the CacheStream class. Expirations can be specified along with priority. |
GetCacheStream(String, String, String, StreamMode, CacheItemPriority) | Gets an instance of the CacheStream class. Groups and subgroups can be specified with priority of the cache item. |
GetCacheStream(String, String, String, StreamMode, CacheDependency, DateTime, TimeSpan, CacheItemPriority) | Gets an instance of the CacheStream class. You can specify if dependency exists. Also groups, subgroups, expiration and priority can be specified. |
GetCacheStream(String, String, String, StreamMode, DateTime, TimeSpan, CacheItemPriority) | Gets an instance of the CacheStream class. Groups and subgroups can be specified with this overload along with expirations and priority. |
GetConnectedClientList() | Returns the list of connected cache clients |
GetEnumerator() | Retrieves a dictionary enumerator used to iterate through the key settings and their values contained in the cache. |
GetGroupData(String, String) | Retrieves the key and value pairs in a group or sub group. |
GetGroupKeys(String, String) | Retrieves the keys of items in a group or sub group. |
GetIfNewer(String, ref CacheItemVersion) | Gets an object from the cache only if a newer version of the object exists in cache. |
GetIfNewer(String, String, String, ref CacheItemVersion) | Gets an object from the cache only if a newer version of the object exists in cache. |
GetKeysByAllTags(Tag[]) | Returns keys that have all the same tags in common. (Returns the Intersection set.) |
GetKeysByAnyTag(Tag[]) | Returns keys that have any of the same tags in common. (Returns the Union set.) |
GetKeysByTag(Tag) | Gets all the keys with the specified tag. |
GetKeysByTag(String) | Gets all the keys with the wild card supported tag. |
GetRunningTasks() | Get All the running tasks. |
GetTaskResult(String) | Get a Trackable instance of the task with specified taskId. |
Insert(String, CacheItem) | Add a CacheItem to the cache |
Insert(String, CacheItem, DSWriteOption, DataSourceItemsUpdatedCallback) | Update a CacheItem in the cache. If item does not exist in cache then it is added. You can specify a delegate for notifying whenever an item is updated in cache. |
Insert(String, CacheItem, DSWriteOption, String, DataSourceItemsUpdatedCallback) | Inserts a CacheItem to the cache if not already existing. Otherwise updates an existing item. Notifies if the item is updated in data source. |
Insert(String, CacheItem, LockHandle, Boolean) | Inserts a CacheItem to the cache if not already existing. Otherwise updates an existing item if it not already locked or if the correct lock-id is specified. |
Insert(String, Object) | Inserts an item into the Cache object with a cache key to reference its location and using default values provided by the CacheItemPriority enumeration. |
Insert(String, Object, NamedTagsDictionary) | Inserts an item into the Cache with a cache key to reference its location and using default values provided by the CacheItemPriority enumeration. It also enables associating named tags with the object. |
Insert(String, Object, Tag[]) | Inserts an item into the Cache with a cache key to reference its location and using default values provided by the CacheItemPriority enumeration. It also enables the associating tags with the object. |
Insert(String, Object, CacheDependency, DateTime, TimeSpan, CacheItemPriority) | Inserts an object into the Cache with dependencies, expiration and priority policies. |
Insert(String, Object, DateTime, TimeSpan, CacheItemPriority) | Inserts an object into the Cache with dependencies, expiration and priority policies. |
Insert(String, Object, String, String) | Insert a value to the cache |
InsertAsync(String, CacheItem, DSWriteOption, DataSourceItemsUpdatedCallback) | Insert a CacheItem to the cache asynchronously |
InsertAsync(String, CacheItem, String, DSWriteOption, DataSourceItemsUpdatedCallback) | Insert a CacheItem to the cache asynchronously. Provider name can be specified with this overload. |
InsertAsync(String, Object, AsyncItemUpdatedCallback, String, String) | Inserts an object into the Cache asynchronously with dependencies, expiration and priority policies, and a delegate you can use to notify your application when the inserted item is removed from the Cache. |
InsertBulk(String[], CacheItem[]) | Insert list of CacheItem to the cache |
InsertBulk(String[], CacheItem[], DSWriteOption, DataSourceItemsUpdatedCallback) | Insert list of CacheItem to the cache. Options regarding updating datasource can be set along with a delegate for notifying if items are updated in datasource. |
InsertBulk(String[], CacheItem[], DSWriteOption, String, DataSourceItemsUpdatedCallback) | Insert list of CacheItem to the cache. Data source provider name along with write-through option can be specified using this overload. You can also specify callback that will be triggered every time item is updated in datasource. |
Invoke(String, IEntryProcessor, DSReadOption, String, DSWriteOption, String, Object[]) | |
Invoke(String, IEntryProcessor, Object[]) | Execution of entry processor regardless of caching topology used, allows to execute code against a cache entry on server side without fetching any data on client side. |
Invoke(String[], IEntryProcessor, DSReadOption, String, DSWriteOption, String, Object[]) | |
Invoke(String[], IEntryProcessor, Object[]) | Execution of entry processor on a set of keys regardless of caching topology used, allows to execute code against a set of cache entries on server side without fetching any data on client side. |
Lock(String, TimeSpan, out LockHandle) | Acquire a lock on an item in cache. |
Log(String, String) | Logs info |
RaiseCustomEvent(Object, Object) | Broadcasts a custom application defined event. |
RegisterCacheNotification(CacheDataNotificationCallback, EventType, EventDataFilter) | Registers ItemAdded, ItemUpdate or ItemRemoved events with cache |
RegisterCacheNotification(String, CacheDataNotificationCallback, EventType) | Registers the ItemUpdate or ItemRemoved events for the specified key. |
RegisterCacheNotification(String, CacheDataNotificationCallback, EventType, EventDataFilter) | Registers the ItemUpdate or ItemRemoved events for the specified key. |
RegisterCacheNotification(String[], CacheDataNotificationCallback, EventType) | Registers the ItemUpdate or ItemRemoved events for the specified keys. |
RegisterCacheNotification(String[], CacheDataNotificationCallback, EventType, EventDataFilter) | Registers the ItemUpdate or ItemRemoved events for the specified keys. |
RegisterCQ(ContinuousQuery) | Registers the notifications based on the specified |
RegisterKeyNotificationCallback(String, CacheItemUpdatedCallback, CacheItemRemovedCallback) | Registers the CacheItemUpdatedCallback and/or CacheItemRemovedCallback for the specified key. |
Remove(String) | Removes the object from the Cache. |
Remove(String, DSWriteOption, DataSourceItemsRemovedCallback) | Removes the object from the Cache. |
Remove(String, DSWriteOption, String, DataSourceItemsRemovedCallback) | Removes the object from the Cache. |
Remove(String, CacheItemVersion) | Removes an item from cache if the specified version is still the most recent version in the cache. |
Remove(String, LockHandle) | Removes an item from cache if it is not already locked or if the correct lock-id is specified. |
RemoveAsync(String, AsyncItemRemovedCallback, DSWriteOption, DataSourceItemsRemovedCallback) | Removes item from cache asynchronously. |
RemoveAsync(String, AsyncItemRemovedCallback, DSWriteOption, String, DataSourceItemsRemovedCallback) | Removes the object from the Cache asynchronously. |
RemoveBulk(String[]) | Removes the objects from the Cache. |
RemoveBulk(String[], DSWriteOption, DataSourceItemsRemovedCallback) | Removes the objects from the Cache. |
RemoveBulk(String[], DSWriteOption, String, DataSourceItemsRemovedCallback) | Removes the objects from the Cache. |
RemoveByAllTags(Tag[]) | Removes the cached objects that have any of the same tags in common. (Returns the Union set.) |
RemoveByAnyTag(Tag[]) | Removes the cached objects that have any of the same tags in common. |
RemoveByTag(Tag) | Removes the cached objects with the specified tag. |
RemoveGroupData(String, String) | Remove the group from cache. |
Search(String, IDictionary) | Performs search on the Cache based on the query specified. |
SearchCQ(ContinuousQuery) | Performs search on the Cache based on the specified |
SearchEntries(String, IDictionary) | This is obsolete method. Use ExecuteReader. Performs search on the Cache based on the query specified. |
SearchEntriesCQ(ContinuousQuery) | Performs search on the Cache based on the specified |
SetAttributes(String, CacheItemAttributes) | Add Attribute existing cache item. |
ToString() | The string representation of the cache object. |
Unlock(String) | Forcefully unlocks a locked cached item. |
Unlock(String, LockHandle) | Unlocks a locked cached item if the correct lock-id is specified. |
UnRegisterCacheNotification(CacheEventDescriptor) | Unregisters a cache level event that may have been registered |
UnRegisterCacheNotification(String, CacheDataNotificationCallback, EventType) | Unregisters event that may have been registered against a specific key |
UnRegisterCacheNotification(String[], CacheDataNotificationCallback, EventType) | Unregisters any event that may have been registered by the user against multiple cache keys |
UnRegisterCQ(ContinuousQuery) | Unregisters notifications for the specified |
UnRegisterKeyNotificationCallback(String, CacheItemUpdatedCallback, CacheItemRemovedCallback) | Unregisters the CacheItemUpdatedCallback and/or CacheItemRemovedCallback already registered for the specified key. |
UnRegisterKeyNotificationCallback(String[], CacheItemUpdatedCallback, CacheItemRemovedCallback) | Unregisters the CacheItemUpdatedCallback and/or CacheItemRemovedCallback already registered for the specified list of keys. |
Name | Description |
---|---|
CacheCleared | Occurs after the Cache is cleared. |
CacheClientConnectivityChanged | Event raised when a cache client connects to or disconnect from cache. (Raised only for outproc caches) |
CacheStopped | Occurs after the cache has been stopped. |
CustomEvent | Occurs in response to a RaiseCustomEvent(Object, Object) method call. |
ItemAdded | Occurs after an item has been added to the Cache. |
ItemRemoved | Occurs after an has been removed from the Cache. |
ItemUpdated | Occurs after an item has been updated in the Cache. |
MemberJoined | Occurs after a new node has joined the cluster. |
MemberLeft | Occurs after a node has left the cluster. |