Class DatabaseCache
Inheritance
DatabaseCache
Assembly: LemonEdge.Database.Connector.dll
Syntax
public class DatabaseCache : IReadOnlyCache
Constructors
DatabaseCache(IDatabaseInfo, long, Guid?, EntityContext, IEntityContextFactory, IEntityDescriptorFactory)
Declaration
public DatabaseCache(IDatabaseInfo dbInfo, long accountID, Guid? canvasID, EntityContext context, IEntityContextFactory entityContextFactory, IEntityDescriptorFactory entityDescriptorFactory)
Parameters
Methods
AddKeyItem(long, Guid?, Type, string, IBaseEntity)
Declaration
public void AddKeyItem(long accountID, Guid? canvasID, Type itemType, string key, IBaseEntity item)
Parameters
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>(long, Guid?, string, Func<Task<T>>)
Declaration
public Task<T> AddKeyItem<T>(long accountID, Guid? canvasID, string key, Func<Task<T>> getNewItem) where T : IBaseEntity
Parameters
Returns
Type Parameters
AddKeyItem<T>(long, Guid?, string, T)
Declaration
public void AddKeyItem<T>(long accountID, Guid? canvasID, string key, T item) where T : IBaseEntity
Parameters
Type Parameters
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
ClearCache(long, bool)
Declaration
public static Task ClearCache(long accountID, bool supressMessageNotification = false)
Parameters
Type |
Name |
Description |
long |
accountID |
|
bool |
supressMessageNotification |
|
Returns
ClearCachedTypes(long, string, bool)
Declaration
public static Task ClearCachedTypes(long accountID, string type, bool supressMessageNotification = false)
Parameters
Type |
Name |
Description |
long |
accountID |
|
string |
type |
|
bool |
supressMessageNotification |
|
Returns
ClearCachedTypes(long, Type[])
Called with distinct set of types being inserted/updated/deleted in the database - changes have been successfully
saved
So if any of those types are being cached we need to clear the cache of those object, or objects dependant on them
Declaration
public static Task ClearCachedTypes(long accountID, Type[] distinctTypesChanged)
Parameters
Type |
Name |
Description |
long |
accountID |
|
Type[] |
distinctTypesChanged |
|
Returns
ClearCachedUsers(bool)
Declaration
public static Task ClearCachedUsers(bool supressMessageNotification = false)
Parameters
Type |
Name |
Description |
bool |
supressMessageNotification |
|
Returns
EnsureMessengerRegistered()
Declaration
public void EnsureMessengerRegistered()
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
GetAllItemsGeneric<T>()
Declaration
public Task<IEnumerable> GetAllItemsGeneric<T>() where T : IBaseEntity
Returns
Type Parameters
GetAllItems<T>()
Retrieves all items of a particular type
Declaration
public Task<IEnumerable<T>> GetAllItems<T>() where T : IBaseEntity
Returns
Type Parameters
Name |
Description |
T |
The type of items to retrieve all items of
|
GetAllItems<T>(long, Guid?)
Declaration
public Task<IEnumerable<T>> GetAllItems<T>(long accountID, Guid? canvasID) where T : IBaseEntity
Parameters
Type |
Name |
Description |
long |
accountID |
|
Guid? |
canvasID |
|
Returns
Type Parameters
GetAndCacheUserByEmail(string)
Declaration
public Task<IUser> GetAndCacheUserByEmail(string email)
Parameters
Type |
Name |
Description |
string |
email |
|
Returns
GetAndCacheUserByToken(string)
Declaration
public Task<IUser> GetAndCacheUserByToken(string token)
Parameters
Type |
Name |
Description |
string |
token |
|
Returns
GetItemGeneric<T>(Guid)
Declaration
public Task<IBaseEntity> GetItemGeneric<T>(Guid id) where T : IBaseEntity
Parameters
Type |
Name |
Description |
Guid |
id |
|
Returns
Type Parameters
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
|
GetItem<T>(long, Guid?, Guid)
Declaration
public Task<T> GetItem<T>(long accountID, Guid? canvasID, Guid id) where T : IBaseEntity
Parameters
Returns
Type Parameters
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
Returns
GetItemsGeneric<T>(QueryableFilter)
Declaration
public Task<IEnumerable> GetItemsGeneric<T>(QueryableFilter filter) where T : IBaseEntity
Parameters
Returns
Type Parameters
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
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
|
GetItems<T>(long, Guid?, QueryableFilter)
Declaration
public Task<IEnumerable<T>> GetItems<T>(long accountID, Guid? canvasID, QueryableFilter filter) where T : IBaseEntity
Parameters
Returns
Type Parameters
GetKeyItem(long, Guid?, Type, string)
Declaration
public (bool, IBaseEntity) GetKeyItem(long accountID, Guid? canvasID, Type itemType, string key)
Parameters
Returns
GetKeyItem(Type, string)
Declaration
public (bool, IBaseEntity) GetKeyItem(Type itemType, string key)
Parameters
Type |
Name |
Description |
Type |
itemType |
|
string |
key |
The key for retrieving this item
|
Returns
GetKeyItem<T>(long, Guid?, string)
Declaration
public (bool, T) GetKeyItem<T>(long accountID, Guid? canvasID, string key) where T : IBaseEntity
Parameters
Returns
Type Parameters
GetKeyItem<T>(string)
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
|
GetWeakKeyItem(string)
Declaration
public object GetWeakKeyItem(string key)
Parameters
Type |
Name |
Description |
string |
key |
|
Returns
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 the cached items that have been created through any AddKeyItem call
Declaration
public void InvalidateKeyItems()
Implements
Extension Methods