Search Results for

    Show / Hide Table of Contents

    Class Cache

    The global local cache (IReadOnlyCache) for the client application.

    A copy is stored locally and is loaded on login or refresh all. By default the cache loads all standing data ( IsStandingDataEntity) entities into the cache.

    When the local cache does not exist, or is out of date, it will load from the system itself and overwrite the local copy
    Inheritance
    object
    Cache
    Implements
    IReadOnlyCache
    IDisposable
    Inherited Members
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: LemonEdge.Client.Core
    Assembly: LemonEdge.Client.Core.dll
    Syntax
    public class Cache : IReadOnlyCache, IDisposable

    Constructors

    Cache(IConnector, IEntityRetriever, IEntityDescriptorFactory, IDomainContextEventHandler)

    Creates a new local cache instance

    Declaration
    public Cache(IConnector connector, IEntityRetriever context, IEntityDescriptorFactory descriptors, IDomainContextEventHandler eventHandler)
    Parameters
    Type Name Description
    IConnector connector
    IEntityRetriever context

    The context to use to load items into the cache

    IEntityDescriptorFactory descriptors
    IDomainContextEventHandler eventHandler

    Properties

    Current

    The current instance of the global local cache for the application

    Declaration
    public static Cache Current { get; }
    Property Value
    Type Description
    Cache

    Methods

    AddKeyItem(Type, string, IBaseEntity)

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

    Declaration
    public void AddKeyItem(Type itemType, string key, IBaseEntity item)
    Parameters
    Type Name Description
    Type itemType
    string key

    The key for retrieving this item

    IBaseEntity item

    The item to add to the cache using this key

    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
    public Task<T> AddKeyItem<T>(string key, Func<Task<T>> getNewItem) where T : IBaseEntity
    Parameters
    Type Name Description
    string key

    The key for retrieving this item

    Func<Task<T>> getNewItem

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

    Returns
    Type Description
    Task<T>

    A task indicating the completion of this function

    Type Parameters
    Name Description
    T

    The type of item to add

    AddKeyItem<T>(string, T)

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

    Declaration
    public void AddKeyItem<T>(string key, T item) where T : IBaseEntity
    Parameters
    Type Name Description
    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

    AddWeakKeyItem(string, object)

    Declaration
    public void AddWeakKeyItem(string key, object item)
    Parameters
    Type Name Description
    string key
    object item

    Dispose()

    Declaration
    public void Dispose()

    GetAllItems(Type)

    Retrieves all items of a particular type

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

    The type of items to retrieve all items of

    Returns
    Type Description
    Task<IEnumerable<IBaseEntity>>

    All items of a particular type

    GetAllItems<T>()

    Retrieves all items of a particular type

    Declaration
    public Task<IEnumerable<T>> GetAllItems<T>() where T : IBaseEntity
    Returns
    Type Description
    Task<IEnumerable<T>>

    All items of a particular type

    Type Parameters
    Name Description
    T

    The type of items to retrieve all items of

    GetItem<T>(Guid)

    Returns a particular item by ID

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

    The ID of the item to return

    Returns
    Type Description
    Task<T>

    A particular item by ID

    Type Parameters
    Name Description
    T

    The type of item to return

    GetItems(Type, QueryableFilter)

    Retrieves items of a particular type according to the specified filter

    Declaration
    public Task<IEnumerable<IBaseEntity>> GetItems(Type t, QueryableFilter filter)
    Parameters
    Type Name Description
    Type t

    The type of items to retrieve

    QueryableFilter filter
    Returns
    Type Description
    Task<IEnumerable<IBaseEntity>>

    Items of a particular type according to the specified filter

    GetItems<T>()

    Declaration
    public Task<IEnumerable<IBaseEntity>> GetItems<T>() where T : IBaseEntity
    Returns
    Type Description
    Task<IEnumerable<IBaseEntity>>
    Type Parameters
    Name Description
    T

    GetItems<T>(QueryableFilter)

    Retrieves items of a particular type according to the specified filter

    Declaration
    public Task<IEnumerable<T>> GetItems<T>(QueryableFilter filter) where T : IBaseEntity
    Parameters
    Type Name Description
    QueryableFilter filter
    Returns
    Type Description
    Task<IEnumerable<T>>

    Items of a particular type according to the specified filter

    Type Parameters
    Name Description
    T

    The type of items to retrieve all items of

    GetKeyItem(Type, string)

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

    Declaration
    public (bool, IBaseEntity) GetKeyItem(Type itemType, string key)
    Parameters
    Type Name Description
    Type itemType
    string key

    The key for retrieving this item

    Returns
    Type Description
    (bool ExistedInCache, IBaseEntity KeyItem)

    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
    public (bool, T) GetKeyItem<T>(string key) where T : IBaseEntity
    Parameters
    Type Name Description
    string key

    The key for retrieving this item

    Returns
    Type Description
    (bool ExistedInCache, T KeyItem)

    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

    GetLoadedItem(Type, Guid)

    Declaration
    public IBaseEntity GetLoadedItem(Type t, Guid id)
    Parameters
    Type Name Description
    Type t
    Guid id
    Returns
    Type Description
    IBaseEntity

    GetLoadedItem(Type, Guid, out IBaseEntity)

    Declaration
    public bool GetLoadedItem(Type t, Guid id, out IBaseEntity item)
    Parameters
    Type Name Description
    Type t
    Guid id
    IBaseEntity item
    Returns
    Type Description
    bool

    GetWeakKeyItem(string)

    Declaration
    public object GetWeakKeyItem(string key)
    Parameters
    Type Name Description
    string key
    Returns
    Type Description
    object

    HasCollectionLoaded(Type)

    Indicates if the specified collection has been loaded into this cache

    Declaration
    public bool HasCollectionLoaded(Type t)
    Parameters
    Type Name Description
    Type t

    The type of item to look for in the cache

    Returns
    Type Description
    bool

    True if the specified type has had its collection loaded into the cache

    InvalidateCachedItem<T>(Guid)

    Invalidate the particular cached item

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

    The id of the item to invalidate

    Returns
    Type Description
    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
    public Task InvalidateCachedItems(Type t)
    Parameters
    Type Name Description
    Type t

    The type of items in the cache to invalidate

    Returns
    Type Description
    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
    public Task InvalidateCachedItems<T>() where T : IBaseEntity
    Returns
    Type Description
    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 all the cached items added via any AddKeyItem call

    Declaration
    public void InvalidateKeyItems()

    IsItemLoaded(Type, Guid)

    Declaration
    public bool IsItemLoaded(Type t, Guid id)
    Parameters
    Type Name Description
    Type t
    Guid id
    Returns
    Type Description
    bool

    Implements

    IReadOnlyCache
    IDisposable

    Extension Methods

    LinqExtensions.AsArray<T>(T)
    LinqExtensions.ToArrayOfOne<T>(T)
    LinqExtensions.ToListOfOne<T>(T)
    MiscExtensions.SetIfNotEqual<T, TP>(T, Expression<Func<T, TP>>, TP)
    WeakReferenceExtensions.WeakReference(object)
    SQLExtensions.ToSQLValue(object, bool)
    ReflectionExtensions.ClearEventInvocations(object, string)
    StringExtensions.ToCSVFormatString(object, Type)
    In this article
    Back to top © LemonEdge Technologies. All rights reserved.