Search Results for

    Show / Hide Table of Contents

    Interface IReadOnlyCache

    An interface for retrieving and cahching items. This should only be used to load standing data items that are frequently refernced but not updated often. Whenever an item is actually changed the cache of those items will be refreshed

    Namespace: LemonEdge.Entities
    Assembly: API.dll
    Syntax
    public interface IReadOnlyCache

    Methods

    AddKeyItem(Type, String, IBaseEntity)

    Adds a specified item to the cache for referral with the specified key

    Declaration
    void AddKeyItem(Type itemType, string key, IBaseEntity item)
    Parameters
    Type Name Description
    System.Type itemType
    System.String key

    The key for retrieving this item

    IBaseEntity item

    The item to add to the cache using this key

    AddKeyItem<T>(String, T)

    Adds a specified item to the cache for referral with the specified key

    Declaration
    void AddKeyItem<T>(string key, T item)
    
        where T : IBaseEntity
    Parameters
    Type Name Description
    System.String key

    The key for retrieving this item

    T item

    The item to add to the cache using this key

    Type Parameters
    Name Description
    T

    The type of item being added to the cache

    AddKeyItem<T>(String, Func<Task<T>>)

    Adds a specified item to the cache in a thread safe manner. Ensures getNewItem is only called if the cache does not already have a value, and getNewItem is not currently being executed for that key

    Declaration
    Task<T> AddKeyItem<T>(string key, Func<Task<T>> getNewItem)
    
        where T : IBaseEntity
    Parameters
    Type Name Description
    System.String key

    The key for retrieving this item

    System.Func<System.Threading.Tasks.Task<T>> getNewItem

    A function that returns the new value if it is needed in a thread safe manner

    Returns
    Type Description
    System.Threading.Tasks.Task<T>

    A task indicating the completion of this function

    Type Parameters
    Name Description
    T

    The type of item to add

    GetAllItems(Type)

    Retrieves all items of a particular type

    Declaration
    Task<IEnumerable<IBaseEntity>> GetAllItems(Type t)
    Parameters
    Type Name Description
    System.Type t

    The type of items to retrieve all items of

    Returns
    Type Description
    System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<IBaseEntity>>

    All items of a particular type

    GetAllItems<T>()

    Retrieves all items of a particular type

    Declaration
    Task<IEnumerable<T>> GetAllItems<T>()
    
        where T : IBaseEntity
    Returns
    Type Description
    System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<T>>

    All items of a particular type

    Type Parameters
    Name Description
    T

    The type of items to retrieve all items of

    GetItem(Type, Guid)

    Returns a particular item by ID

    Declaration
    virtual Task<IBaseEntity> GetItem(Type type, Guid id)
    Parameters
    Type Name Description
    System.Type type

    The type of item to return

    System.Guid id

    The ID of the item to return

    Returns
    Type Description
    System.Threading.Tasks.Task<IBaseEntity>

    A particular item by ID

    GetItem<T>(Guid)

    Returns a particular item by ID

    Declaration
    Task<T> GetItem<T>(Guid id)
    
        where T : IBaseEntity
    Parameters
    Type Name Description
    System.Guid id

    The ID of the item to return

    Returns
    Type Description
    System.Threading.Tasks.Task<T>

    A particular item by ID

    Type Parameters
    Name Description
    T

    The type of item to return

    GetKeyItem(Type, String)

    Retrieves a previously added key item (through AddKeyItem(Type, String, IBaseEntity)) using the specified key.

    Declaration
    (bool ExistedInCache, IBaseEntity KeyItem) GetKeyItem(Type itemType, string key)
    Parameters
    Type Name Description
    System.Type itemType
    System.String key

    The key for retrieving this item

    Returns
    Type Description
    System.ValueTuple<System.Boolean, IBaseEntity>

    Returns true if the key was added to the cache and returns the item. False and null otherwise

    GetKeyItem<T>(String)

    Retrieves a previously added key item (through AddKeyItem<T>(String, T)) using the specified key.

    Declaration
    (bool ExistedInCache, T KeyItem) GetKeyItem<T>(string key)
    
        where T : IBaseEntity
    Parameters
    Type Name Description
    System.String key

    The key for retrieving this item

    Returns
    Type Description
    System.ValueTuple<System.Boolean, T>

    Returns true if the key was added to the cache and returns the item. False and null otherwise

    Type Parameters
    Name Description
    T

    The type of item to retrieve from the cache

    InvalidateCachedItem<T>(Guid)

    Invalidate the particular cached item

    Declaration
    Task InvalidateCachedItem<T>(Guid id)
    
        where T : IBaseEntity
    Parameters
    Type Name Description
    System.Guid id

    The id of the item to invalidate

    Returns
    Type Description
    System.Threading.Tasks.Task

    A task indicating when the operation is complete

    Type Parameters
    Name Description
    T

    The type of the item in the cache to invalidate

    InvalidateCachedItems(Type)

    Invalidates all cached items of a particular type. Called whenever a context saves changes to items of this type

    Declaration
    Task InvalidateCachedItems(Type t)
    Parameters
    Type Name Description
    System.Type t

    The type of items in the cache to invalidate

    Returns
    Type Description
    System.Threading.Tasks.Task

    A task indicating when the operation is complete

    InvalidateCachedItems<T>()

    Invalidates all cached items of a particular type. Called whenever a context saves changes to items of this type

    Declaration
    Task InvalidateCachedItems<T>()
    
        where T : IBaseEntity
    Returns
    Type Description
    System.Threading.Tasks.Task

    A task indicating when the operation is complete

    Type Parameters
    Name Description
    T

    The type of items in the cache to invalidate

    InvalidateKeyItems()

    Invalidates the cached items that have been created through any AddKeyItem call

    Declaration
    void InvalidateKeyItems()

    Extension Methods

    MiscExtensions.SetIfNotEqual<T, P>(T, Expression<Func<T, P>>, P)
    ReflectionExtensions.ClearEventInvocations(Object, String)
    StringExtensions.ToCSVFormatString(Object, Type)
    SQLExtensions.ToSQLValue(Object, Boolean)
    In This Article
    Back to top © LemonEdge Technology. All rights reserved.