Interface ICacheEnumerable<TKey>
- Namespace
- Cuemon.Runtime.Caching
- Assembly
- Cuemon.Runtime.Caching.dll
An interface that is used to provide cache implementations for an application.
public interface ICacheEnumerable<TKey> : IEnumerable<KeyValuePair<TKey, CacheEntry>>, IEnumerable
Type Parameters
TKey
The type of the key in the cache.
- Inherited Members
Properties
Item[String, String]
Gets or sets a value in the cache by using the default indexer property for an instance of the SlimMemoryCache class.
object this[string key, string ns = null ] { get; set; }
Parameters
key
StringThe unique identifier for the cache value to get or set.
ns
StringThe optional named group associated with the cache value.
Property Value
- Object
The value in the cache for the specified
key
, if the entry exists; otherwise,null
.
KeyProvider
Gets the function delegate that is responsible for providing a unique identifier for the cache entry.
Func<string, string, TKey> KeyProvider { get; }
Property Value
- Func<String, String, TKey>
The function delegate that is responsible for providing a unique identifier for the cache entry.
Methods
Add(CacheEntry, CacheInvalidation)
Inserts a cache entry into the cache as a CacheEntry instance, and adds details about how the entry should be evicted.
bool Add(CacheEntry entry, CacheInvalidation invalidation)
Parameters
entry
CacheEntryThe object representing the cached value for a cache entry.
invalidation
CacheInvalidationThe object that contains expiration details for a specific cache entry.
Returns
Contains(String, String)
Determines whether a cache entry exists in the cache.
bool Contains(string key, string ns = null)
Parameters
key
StringThe unique identifier for the cache entry.
ns
StringThe optional namespace that provides a scope to the cache.
Returns
- Boolean
true
if the cache contains a cache entry whose key matcheskey
; otherwise,false
.
Count(String)
Gets the number of entries associated with the ns
contained in the cache.
int Count(string ns = null)
Parameters
ns
StringThe optional namespace that provides a scope to the cache.
Returns
- Int32
The number of entries contained in the cache.
Get(String, String)
Returns an entry from the cache.
object Get(string key, string ns = null)
Parameters
key
StringThe unique identifier for the cache entry.
ns
StringThe optional namespace that provides a scope to the cache.
Returns
- Object
A reference to the value in the cache container that is identified by
key
, if the entry exists; otherwise,null
.
GetCacheEntry(String, String)
Returns an entry from the cache as a CacheEntry instance.
CacheEntry GetCacheEntry(string key, string ns = null)
Parameters
key
StringThe unique identifier for the cache entry.
ns
StringThe optional namespace that provides a scope to the cache.
Returns
- CacheEntry
A reference to the CacheEntry that is identified by
key
, if the entry exists; otherwise,null
.
Remove(String, String)
Removes a cache entry from the cache.
object Remove(string key, string ns = null)
Parameters
key
StringThe unique identifier for the cache entry.
ns
StringThe optional namespace that provides a scope to the cache.
Returns
- Object
If the entry is found in the cache, a reference to the value in the cache container of the removed cache entry; otherwise,
null
.
RemoveAll(String)
Removes all entries associated with the ns
contained in the cache.
void RemoveAll(string ns = null)
Parameters
ns
StringThe optional namespace that provides a scope to the cache.
Set(String, Object, CacheInvalidation, String)
Inserts a cache entry into the cache.
void Set(string key, object value, CacheInvalidation invalidation, string ns = null)
Parameters
key
StringThe unique identifier of the cache.
value
ObjectThe stored value of the cache.
invalidation
CacheInvalidationThe object that contains expiration details for a specific cache entry.
ns
StringThe optional namespace that provides a scope to the cache.
TryGet(String, out Object)
Attempts to get the value associated with the specified key
from the cache.
bool TryGet(string key, out object value)
Parameters
key
StringThe unique identifier for the cache entry.
value
ObjectWhen this method returns, contains the value associated with the specified
key
, ornull
if the operation failed.
Returns
- Boolean
true
if thevalue
was found in the cache; otherwise,false
.
TryGet(String, String, out Object)
Attempts to get the value associated with the specified key
and ns
from the cache.
bool TryGet(string key, string ns, out object value)
Parameters
key
StringThe unique identifier for the cache entry.
ns
StringThe optional namespace that provides a scope to the cache.
value
ObjectWhen this method returns, contains the value associated with the specified
key
andns
, ornull
if the operation failed.
Returns
- Boolean
true
if thevalue
was found in the cache; otherwise,false
.
TryGetCacheEntry(String, out CacheEntry)
Attempts to get the CacheEntry associated with the specified key
from the cache.
bool TryGetCacheEntry(string key, out CacheEntry cacheEntry)
Parameters
key
StringThe unique identifier for the cache entry.
cacheEntry
CacheEntryWhen this method returns, contains the cache entry associated with the specified
key
, ornull
if the operation failed.
Returns
- Boolean
true
if thecacheEntry
was found in the cache; otherwise,false
.
TryGetCacheEntry(String, String, out CacheEntry)
Attempts to get the CacheEntry associated with the specified key
and ns
from the cache.
bool TryGetCacheEntry(string key, string ns, out CacheEntry cacheEntry)
Parameters
key
StringThe unique identifier for the cache entry.
ns
StringThe optional namespace that provides a scope to the cache.
cacheEntry
CacheEntryWhen this method returns, contains the cache entry associated with the specified
key
andns
, ornull
if the operation failed.
Returns
- Boolean
true
if thecacheEntry
was found in the cache; otherwise,false
.