Class DictionaryAppCache
Implements IAppCache on top of a concurrent dictionary.
Inheritance
Namespace: Umbraco.Cms.Core.Cache
Assembly: Umbraco.Core.dll
Syntax
public class DictionaryAppCache : IRequestCache, IAppCache
Constructors
View SourceDictionaryAppCache()
Declaration
public DictionaryAppCache()
Properties
View SourceCount
Gets the number of items in the cache.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int |
IsAvailable
Gets a value indicating whether the request cache is available.
Declaration
public bool IsAvailable { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
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).
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 virtual 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.
GetEnumerator()
Returns an enumerator that iterates through the cache items.
Declaration
public IEnumerator<KeyValuePair<string, object?>> GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator<KeyValuePair<string, object>> | An enumerator for the cache items. |
Remove(string)
Removes a value from the request cache.
Declaration
public bool Remove(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The key of the item to remove. |
Returns
| Type | Description |
|---|---|
| bool |
|
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 IEnumerable<object?> SearchByRegex(string regex)
Parameters
| Type | Name | Description |
|---|---|---|
| string | regex | The regular expression. |
Returns
| Type | Description |
|---|---|
| IEnumerable<object> | Items matching the search. |
Set(string, object?)
Sets a value in the request cache.
Declaration
public bool Set(string key, object? value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The key of the item to set. |
| object | value | The value to store in the cache. |
Returns
| Type | Description |
|---|---|
| bool |
|