Interface ICacheEnumerable<TKey>
An interface that is used to provide cache implementations for an application.
public interface ICacheEnumerable<TKey> : IEnumerable<KeyValuePair<TKey, CacheEntry>>, IEnumerable
Type Parameters
TKeyThe type of the key in the cache.
- Inherited Members
Properties
this[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
keystringThe unique identifier for the cache value to get or set.
nsstringThe 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
entryCacheEntryThe object representing the cached value for a cache entry.
invalidationCacheInvalidationThe 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
keystringThe unique identifier for the cache entry.
nsstringThe optional namespace that provides a scope to the cache.
Returns
- bool
trueif 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
nsstringThe optional namespace that provides a scope to the cache.
Returns
- int
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
keystringThe unique identifier for the cache entry.
nsstringThe 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
keystringThe unique identifier for the cache entry.
nsstringThe 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
keystringThe unique identifier for the cache entry.
nsstringThe 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
nsstringThe 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
keystringThe unique identifier of the cache.
valueobjectThe stored value of the cache.
invalidationCacheInvalidationThe object that contains expiration details for a specific cache entry.
nsstringThe 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
keystringThe unique identifier for the cache entry.
valueobjectWhen this method returns, contains the value associated with the specified
key, ornullif the operation failed.
Returns
- bool
trueif thevaluewas 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
keystringThe unique identifier for the cache entry.
nsstringThe optional namespace that provides a scope to the cache.
valueobjectWhen this method returns, contains the value associated with the specified
keyandns, ornullif the operation failed.
Returns
- bool
trueif thevaluewas 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
keystringThe unique identifier for the cache entry.
cacheEntryCacheEntryWhen this method returns, contains the cache entry associated with the specified
key, ornullif the operation failed.
Returns
- bool
trueif thecacheEntrywas 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
keystringThe unique identifier for the cache entry.
nsstringThe optional namespace that provides a scope to the cache.
cacheEntryCacheEntryWhen this method returns, contains the cache entry associated with the specified
keyandns, ornullif the operation failed.
Returns
- bool
trueif thecacheEntrywas found in the cache; otherwise,false.