Method Clear
Clear()
Removes all elements from the Cache.
Declaration
[TargetMethod(1)]
public virtual void Clear()
Remarks
In most of the cases this method's implementation is close to O(1).
Note: If exceptions are enabled through the ExceptionsEnabled setting, this property throws exception incase of failure.
Examples
The following example demonstrates how to check for containment of an item in the Cache.
Cache cache = NCache.InitializeCache("myCache");
cache.Clear();
Clear(DSWriteOption, DataSourceClearedCallback)
Removes all elements from the Cache.
Declaration
[TargetMethod(2)]
[Obsolete("This method is deprecated. 'Please use Clear()'", false)]
public virtual void Clear(DSWriteOption updateOpt, DataSourceClearedCallback dataSourceClearedCallback)
Parameters
Type | Name | Description |
---|---|---|
DSWriteOption | updateOpt | Options regarding updating data source |
DataSourceClearedCallback | dataSourceClearedCallback | A delegate that, if provided, is called when data source is cleared. |
Remarks
In most of the cases this method's implementation is close to O(1).
Note: If exceptions are enabled through the ExceptionsEnabled setting, this property throws exception incase of failure.
Examples
The following example demonstrates how to clear the Cache.
OnDataSourceCleared(object result)
{
...
}
Cache cache = NCache.InitializeCache("myCache");
cache.Clear(DSWriteOption.WriteBehind, new DataSourceClearedCallback(OnDataSourceCleared));