Class FastDictionaryAppCacheBase
Provides a base class to fast, dictionary-based IAppCache implementations.
Inheritance
Namespace: Umbraco.Cms.Core.Cache
Assembly: Umbraco.Core.dll
Syntax
public abstract class FastDictionaryAppCacheBase : IAppCache
Constructors
View SourceFastDictionaryAppCacheBase()
Declaration
protected FastDictionaryAppCacheBase()
Fields
View SourceCacheItemPrefix
The prefix used for all cache keys to distinguish them from other cache entries.
Declaration
protected const string CacheItemPrefix = "umbrtmche"
Field Value
| Type | Description |
|---|---|
| string |
Methods
View SourceClear()
Removes all items from the cache.
Declaration
public virtual void Clear()
Clear(string)
Removes an item identified by its key from the cache.
Declaration
public virtual void Clear(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The key of the item. |
ClearByKey(string)
Clears items with a key starting with the specified value.
Declaration
public virtual void ClearByKey(string keyStartsWith)
Parameters
| Type | Name | Description |
|---|---|---|
| string | keyStartsWith | The StartsWith value to use in the search. |
ClearByRegex(string)
Clears items with a key matching a regular expression.
Declaration
public virtual void ClearByRegex(string regex)
Parameters
| Type | Name | Description |
|---|---|---|
| string | regex | The regular expression. |
ClearOfType(Type?)
Removes items of a specified type from the cache.
Declaration
public virtual void ClearOfType(Type? type)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | type | The type to remove. |
Remarks
If the type is an interface, then all items of a type implementing that interface are removed. Otherwise, only items of that exact type are removed (items of type inheriting from the specified type are not removed).
Performs a case-sensitive search.
ClearOfType<T>()
Removes items of a specified type from the cache.
Declaration
public virtual void ClearOfType<T>()
Type Parameters
| Name | Description |
|---|---|
| T | The type of the items to remove. |
Remarks
If the type is an interface, then all items of a type implementing that interface are removed. Otherwise, only items of that exact type are removed (items of type inheriting from the specified type are not removed).
ClearOfType<T>(Func<string, T, bool>)
Removes items of a specified type from the cache.
Declaration
public virtual void ClearOfType<T>(Func<string, T, bool> predicate)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<string, T, bool> | predicate | The predicate to satisfy. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the items to remove. |
Remarks
If the type is an interface, then all items of a type implementing that interface are removed. Otherwise, only items of that exact type are removed (items of type inheriting from the specified type are not removed).
EnterReadLock()
Enters a read lock on the underlying cache.
Declaration
protected abstract void EnterReadLock()
EnterWriteLock()
Enters a write lock on the underlying cache.
Declaration
protected abstract void EnterWriteLock()
ExitReadLock()
Exits the read lock on the underlying cache.
Declaration
protected abstract void ExitReadLock()
ExitWriteLock()
Exits the write lock on the underlying cache.
Declaration
protected abstract void ExitWriteLock()
Get(string)
Gets an item identified by its key.
Declaration
public virtual object? Get(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The key of the item. |
Returns
| Type | Description |
|---|---|
| object | The item, or null if the item was not found. |
Get(string, Func<object?>)
Gets or creates an item identified by its key.
Declaration
public abstract object? Get(string key, Func<object?> factory)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The key of the item. |
| Func<object> | factory | A factory function that can create the item. |
Returns
| Type | Description |
|---|---|
| object | The item. |
Remarks
Null values returned from the factory function are never cached.
GetCacheKey(string)
Gets the prefixed cache key.
Declaration
protected string GetCacheKey(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The public cache key. |
Returns
| Type | Description |
|---|---|
| string | The full prefixed cache key. |
GetDictionaryEntries()
Gets all dictionary entries from the underlying cache.
Declaration
protected abstract IEnumerable<KeyValuePair<object, object>> GetDictionaryEntries()
Returns
| Type | Description |
|---|---|
| IEnumerable<KeyValuePair<object, object>> | The dictionary entries. |
Remarks
Must be called from within the appropriate locks.
GetEntry(string)
Gets an entry from the underlying cache.
Declaration
protected abstract object? GetEntry(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The full prefixed cache key. |
Returns
| Type | Description |
|---|---|
| object | The cached value, or |
Remarks
Must be called from within the appropriate locks.
RemoveEntry(string)
Removes an entry from the underlying cache.
Declaration
protected abstract void RemoveEntry(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The full prefixed cache key. |
Remarks
Must be called from within the appropriate locks.
SearchByKey(string)
Gets items with a key starting with the specified value.
Declaration
public virtual IEnumerable<object> SearchByKey(string keyStartsWith)
Parameters
| Type | Name | Description |
|---|---|---|
| string | keyStartsWith | The StartsWith value to use in the search. |
Returns
| Type | Description |
|---|---|
| IEnumerable<object> | Items matching the search. |
SearchByRegex(string)
Gets items with a key matching a regular expression.
Declaration
public virtual IEnumerable<object?> SearchByRegex(string regex)
Parameters
| Type | Name | Description |
|---|---|---|
| string | regex | The regular expression. |
Returns
| Type | Description |
|---|---|
| IEnumerable<object> | Items matching the search. |