Class ObjectCacheAppCache
Implements IAppPolicyCache on top of a System.Runtime.Caching.ObjectCache.
Inheritance
Namespace: Umbraco.Core.Cache
Assembly: Umbraco.Core.dll
Syntax
public class ObjectCacheAppCache : IAppPolicyCache, IAppCache, IDisposable
Constructors
View SourceObjectCacheAppCache()
Initializes a new instance of the ObjectCacheAppCache.
Declaration
public ObjectCacheAppCache()
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 |
---|---|---|
System.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 |
---|---|---|
System.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 |
---|---|---|
System.String | regex | The regular expression. |
ClearOfType(String)
Removes items of a specified type from the cache.
Declaration
public virtual void ClearOfType(string typeName)
Parameters
Type | Name | Description |
---|---|---|
System.String | typeName | The name of 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, Boolean>)
Removes items of a specified type from the cache.
Declaration
public virtual void ClearOfType<T>(Func<string, T, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.String, T, System.Boolean> | 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).
Dispose()
Declaration
public void Dispose()
Dispose(Boolean)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
Get(String)
Gets an item identified by its key.
Declaration
public object Get(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key of the item. |
Returns
Type | Description |
---|---|
System.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 object Get(string key, Func<object> factory)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key of the item. |
System.Func<System.Object> | factory | A factory function that can create the item. |
Returns
Type | Description |
---|---|
System.Object | The item. |
Get(String, Func<Object>, Nullable<TimeSpan>, Boolean, CacheItemPriority, CacheItemRemovedCallback, String[])
Gets an item identified by its key.
Declaration
public object Get(string key, Func<object> factory, TimeSpan? timeout, bool isSliding = false, CacheItemPriority priority = CacheItemPriority.Normal, CacheItemRemovedCallback removedCallback = null, string[] dependentFiles = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key of the item. |
System.Func<System.Object> | factory | A factory function that can create the item. |
System.Nullable<System.TimeSpan> | timeout | An optional cache timeout. |
System.Boolean | isSliding | An optional value indicating whether the cache timeout is sliding (default is false). |
System.Web.Caching.CacheItemPriority | priority | An optional cache priority (default is Normal). |
System.Web.Caching.CacheItemRemovedCallback | removedCallback | An optional callback to handle removals. |
System.String[] | dependentFiles | Files the cache entry depends on. |
Returns
Type | Description |
---|---|
System.Object | The item. |
Insert(String, Func<Object>, Nullable<TimeSpan>, Boolean, CacheItemPriority, CacheItemRemovedCallback, String[])
Inserts an item.
Declaration
public void Insert(string key, Func<object> factory, TimeSpan? timeout = null, bool isSliding = false, CacheItemPriority priority = CacheItemPriority.Normal, CacheItemRemovedCallback removedCallback = null, string[] dependentFiles = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key of the item. |
System.Func<System.Object> | factory | A factory function that can create the item. |
System.Nullable<System.TimeSpan> | timeout | An optional cache timeout. |
System.Boolean | isSliding | An optional value indicating whether the cache timeout is sliding (default is false). |
System.Web.Caching.CacheItemPriority | priority | An optional cache priority (default is Normal). |
System.Web.Caching.CacheItemRemovedCallback | removedCallback | An optional callback to handle removals. |
System.String[] | dependentFiles | Files the cache entry depends on. |
SearchByKey(String)
Gets items with a key starting with the specified value.
Declaration
public IEnumerable<object> SearchByKey(string keyStartsWith)
Parameters
Type | Name | Description |
---|---|---|
System.String | keyStartsWith | The StartsWith value to use in the search. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.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 |
---|---|---|
System.String | regex | The regular expression. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Object> | Items matching the search. |