Search Results for

    Show / Hide Table of Contents
    View Source

    Class AppCacheExtensions

    Provides extension methods for strongly typed access to IAppCache and IAppPolicyCache.

    Inheritance
    object
    Namespace: Umbraco.Extensions
    Assembly: Umbraco.Core.dll
    Syntax
    public static class AppCacheExtensions

    Methods

    View Source

    GetCacheItemAsync<T>(IAppPolicyCache, string, Func<Task<T?>>, TimeSpan?, bool)

    Asynchronously gets a strongly typed cache item with the specified key, creating it if necessary using the provided factory.

    Declaration
    public static Task<T?> GetCacheItemAsync<T>(this IAppPolicyCache provider, string cacheKey, Func<Task<T?>> getCacheItemAsync, TimeSpan? timeout, bool isSliding = false)
    Parameters
    Type Name Description
    IAppPolicyCache provider

    The cache provider.

    string cacheKey

    The cache key.

    Func<Task<T>> getCacheItemAsync

    An async factory function that creates the item if not found.

    TimeSpan? timeout

    An optional cache timeout.

    bool isSliding

    Whether the timeout is sliding (resets on access).

    Returns
    Type Description
    Task<T>

    A task representing the asynchronous operation, containing the cached item.

    Type Parameters
    Name Description
    T

    The type of the cached item.

    View Source

    GetCacheItem<T>(IAppCache, string)

    Gets a strongly typed cache item with the specified key.

    Declaration
    public static T? GetCacheItem<T>(this IAppCache provider, string cacheKey)
    Parameters
    Type Name Description
    IAppCache provider

    The cache provider.

    string cacheKey

    The cache key.

    Returns
    Type Description
    T

    The cached item, or default if not found.

    Type Parameters
    Name Description
    T

    The type of the cached item.

    View Source

    GetCacheItem<T>(IAppCache, string, Func<T>)

    Gets a strongly typed cache item with the specified key, creating it if necessary using the provided factory.

    Declaration
    public static T? GetCacheItem<T>(this IAppCache provider, string cacheKey, Func<T> getCacheItem)
    Parameters
    Type Name Description
    IAppCache provider

    The cache provider.

    string cacheKey

    The cache key.

    Func<T> getCacheItem

    A factory function that creates the item if not found.

    Returns
    Type Description
    T

    The cached item, or default if not found and factory returns null.

    Type Parameters
    Name Description
    T

    The type of the cached item.

    View Source

    GetCacheItem<T>(IAppPolicyCache, string, Func<T?>, TimeSpan?, bool)

    Gets a strongly typed cache item with the specified key, creating it if necessary using the provided factory.

    Declaration
    public static T? GetCacheItem<T>(this IAppPolicyCache provider, string cacheKey, Func<T?> getCacheItem, TimeSpan? timeout, bool isSliding = false)
    Parameters
    Type Name Description
    IAppPolicyCache provider

    The cache provider.

    string cacheKey

    The cache key.

    Func<T> getCacheItem

    A factory function that creates the item if not found.

    TimeSpan? timeout

    An optional cache timeout.

    bool isSliding

    Whether the timeout is sliding (resets on access).

    Returns
    Type Description
    T

    The cached item, or default if not found and factory returns null.

    Type Parameters
    Name Description
    T

    The type of the cached item.

    View Source

    GetCacheItemsByKeyExpression<T>(IAppCache, string)

    Gets strongly typed cache items with keys matching a regular expression.

    Declaration
    public static IEnumerable<T?> GetCacheItemsByKeyExpression<T>(this IAppCache provider, string regexString)
    Parameters
    Type Name Description
    IAppCache provider

    The cache provider.

    string regexString

    The regular expression pattern to match keys against.

    Returns
    Type Description
    IEnumerable<T>

    A collection of cached items matching the search.

    Type Parameters
    Name Description
    T

    The type of the cached items.

    View Source

    GetCacheItemsByKeySearch<T>(IAppCache, string)

    Gets strongly typed cache items with keys starting with the specified value.

    Declaration
    public static IEnumerable<T?> GetCacheItemsByKeySearch<T>(this IAppCache provider, string keyStartsWith)
    Parameters
    Type Name Description
    IAppCache provider

    The cache provider.

    string keyStartsWith

    The key prefix to search for.

    Returns
    Type Description
    IEnumerable<T>

    A collection of cached items matching the search.

    Type Parameters
    Name Description
    T

    The type of the cached items.

    View Source

    InsertCacheItemAsync<T>(IAppPolicyCache, string, Func<Task<T>>, TimeSpan?, bool)

    Asynchronously inserts a strongly typed cache item with the specified key.

    Declaration
    public static Task InsertCacheItemAsync<T>(this IAppPolicyCache provider, string cacheKey, Func<Task<T>> getCacheItemAsync, TimeSpan? timeout = null, bool isSliding = false)
    Parameters
    Type Name Description
    IAppPolicyCache provider

    The cache provider.

    string cacheKey

    The cache key.

    Func<Task<T>> getCacheItemAsync

    An async factory function that creates the item to cache.

    TimeSpan? timeout

    An optional cache timeout.

    bool isSliding

    Whether the timeout is sliding (resets on access).

    Returns
    Type Description
    Task

    A task representing the asynchronous operation.

    Type Parameters
    Name Description
    T

    The type of the cached item.

    View Source

    InsertCacheItem<T>(IAppPolicyCache, string, Func<T>, TimeSpan?, bool)

    Inserts a strongly typed cache item with the specified key.

    Declaration
    public static void InsertCacheItem<T>(this IAppPolicyCache provider, string cacheKey, Func<T> getCacheItem, TimeSpan? timeout = null, bool isSliding = false)
    Parameters
    Type Name Description
    IAppPolicyCache provider

    The cache provider.

    string cacheKey

    The cache key.

    Func<T> getCacheItem

    A factory function that creates the item to cache.

    TimeSpan? timeout

    An optional cache timeout.

    bool isSliding

    Whether the timeout is sliding (resets on access).

    Type Parameters
    Name Description
    T

    The type of the cached item.

    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX