Class CacheManager
Utility class for dealing with caches.
Assembly: SoDataBase.BusinessLogic.dll
Syntax
public class CacheManager : ICacheManager
Constructors
CacheManager(DatabaseInstanceContainer, IOptions<OnlineConfiguration>, ILogger<CacheManager>)
Utility class for dealing with caches.
Declaration
public CacheManager(DatabaseInstanceContainer cacheContainer, IOptions<ConfigFile.OnlineConfiguration> onlineConfiguration, ILogger<CacheManager> logger)
Parameters
Properties
CacheCheckTimer
Timer to synchronize caches with CacheInvalidationTableInfo.
Declaration
public Timer CacheCheckTimer { get; }
Property Value
ForceRefreshTimer
Timer to force cache refresh.
Declaration
public Timer ForceRefreshTimer { get; }
Property Value
Methods
AddAutoDisableTables(string[])
Enter scope - disable auto-update of caches depending on any of the given tables by incrementing the disable-count
Declaration
public void AddAutoDisableTables(string[] namesToDisable)
Parameters
| Type |
Name |
Description |
| string[] |
namesToDisable |
|
Flush(params CacheBaseV2[])
Removes the cache instance from the system so it'll be queued for GC, next time we request the
cache it will be recreated.
Declaration
public void Flush(params CacheBaseV2[] caches)
Parameters
Flush<T>()
Removes the cache instance from the system so it'll be queued for GC, next time we request the
cache it will be recreated.
Declaration
public void Flush<T>() where T : CacheBaseV2
Type Parameters
GetAllCacheNames()
Returns names of all caches, not just the tables
Declaration
public IEnumerable<string> GetAllCacheNames()
Returns
GetAllCachesByTableNames()
Get a lookup that leads from table name to caches dependent on that table
Declaration
public ILookup<string, CacheBaseV2> GetAllCachesByTableNames()
Returns
GetAllCachesInContext()
Utility class for dealing with caches.
Declaration
public IEnumerable<CacheBaseV2> GetAllCachesInContext()
Returns
GetOrCreateAsync<T>(CancellationToken)
This method is declare sync, but returns a ValueTaskT. It contains a private
async method that does any needed async/await work, but this happens rarely and we avoid having
the whole async state machine (and async "contagion" to outside clients.
Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
public ValueTask<T> GetOrCreateAsync<T>(CancellationToken cancellationToken = default) where T : CacheBaseV2
Parameters
Returns
Type Parameters
GetOrCreate<T>()
This method is declare sync, but returns a ValueTaskT. It contains a private
async method that does any needed async/await work, but this happens rarely and we avoid having
the whole async state machine (and async "contagion" to outside clients.
Declaration
public T GetOrCreate<T>() where T : CacheBaseV2
Returns
Type Parameters
InstanceDispose()
Utility class for dealing with caches.
Declaration
public void InstanceDispose()
IsAutoUpdateDisabled(string)
Determine if automatic updates are disabled for a particular table (not a particular cache!)
Declaration
public bool IsAutoUpdateDisabled(string tableName)
Parameters
| Type |
Name |
Description |
| string |
tableName |
|
Returns
RegisterAsync(CacheBaseV2, CancellationToken)
Register a cache within the caching system. This is typically called by the CacheBaseV2 cache base class.
Declaration
public Task RegisterAsync(CacheBaseV2 cache, CancellationToken cancellationToken = default)
Parameters
Returns
RegisterAsync(string[], CancellationToken)
Utility class for dealing with caches.
Declaration
public Task RegisterAsync(string[] cachedTables, CancellationToken cancellationToken = default)
Parameters
Returns
RegisterCacheInvalidationAsync(string, CancellationToken)
Register (by writing to the CacheInvalidation table) that a cached table has been changed
Declaration
public Task RegisterCacheInvalidationAsync(string tableName, CancellationToken cancellationToken = default)
Parameters
Returns
RemoveAutoDisableTablesAsync(string[], CancellationToken)
Exit scope - decrement disable-count of each given table; update each dependent cache once; wait for cache update to complete
Declaration
public Task RemoveAutoDisableTablesAsync(string[] namesToReenable, CancellationToken cancellationToken = default)
Parameters
Returns
Unregister(CacheBaseV2)
Unregisters a cache from the cache system. Next time you get a cache it will be a new instance with fresh data.
Declaration
public void Unregister(CacheBaseV2 cache)
Parameters
| Type |
Name |
Description |
| CacheBaseV2 |
cache |
Cache to unregister.
|
Implements
Extension Methods