Method Contains
Contains(String)
Determines whether the cache contains a specific key.
Declaration
bool Contains(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to locate in the ICache. |
Returns
Type | Description |
---|---|
System.Boolean | true if the ICache contains an element with the specified key; otherwise, false. |
Remarks
In most of the cases this method's implementation is close to O(1).
Note: In a partitioned cluster this operation is an expensive one as it might result in network calls. It is therefore advised to use this property only when required.
Examples
The following example demonstrates how to check for containment of an item in the ICache
ICache cache = CacheManager.GetCache("myCache");
if(cache.Contains("Product0"))
{
Response.Write("Item found!");
}