Method ClearAsync
ClearAsync(AsyncCacheClearedCallback)
Removes all elements from the Cache asynchronously.
Declaration
public virtual void ClearAsync(AsyncCacheClearedCallback onAsyncCacheClearCallback)
Parameters
Type | Name | Description |
---|---|---|
AsyncCacheClearedCallback | onAsyncCacheClearCallback |
Remarks
This is similar to Clear() except that the operation is performed asynchronously. A CacheCleared event is fired upon successful completion of this method.It is not possible to determine if the actual operation has failed, therefore use this operation for the cases when it does not matter much.
Note: If exceptions are enabled through the ExceptionsEnabled setting, this property throws exception in case of failure.
A delegate that, if provided, is called when data source is cleared. A delegate that, that can be used to get the result of the Asynchronous Clear operation. Options regarding updating data sourceExamples
The following example demonstrates how to clear the Cache.
void OnAsyncCacheCleared(object result)
{
...
}
Cache _cache = NCache.InitializeCache("myCache");
_cache.ClearAsync(new AsyncCacheClearedCallback(OnAsyncCacheCleared));
ClearAsync(DSWriteOption, AsyncCacheClearedCallback, DataSourceClearedCallback)
Removes all elements from the Cache asynchronously.
Declaration
[Obsolete("This method is deprecated. 'Please use Clear()'", false)]
public virtual void ClearAsync(DSWriteOption updateOpt, AsyncCacheClearedCallback onAsyncCacheClearCallback, DataSourceClearedCallback dataSourceClearedCallback)
Parameters
Type | Name | Description |
---|---|---|
DSWriteOption | updateOpt | |
AsyncCacheClearedCallback | onAsyncCacheClearCallback | |
DataSourceClearedCallback | dataSourceClearedCallback |
Remarks
This is similar to Clear() except that the operation is performed asynchronously. A CacheCleared event is fired upon successful completion of this method.It is not possible to determine if the actual operation has failed, therefore use this operation for the cases when it does not matter much.
Note: If exceptions are enabled through the ExceptionsEnabled setting, this property throws exception in case of failure.
Enum for specifying DSWriteOperation Delegate that is called if item is cleared from cache. Delegate that is called if item cleared from data source.