Class CacheBaseV2
Base class for caches.
Inheritance
Inherited Members
Namespace: SuperOffice.Data.Cache
Assembly: SoDataBase.dll
Syntax
public abstract class CacheBaseV2
Remarks
Implement this class if you want to implement a cache within NetServer. Classes implementing this class should always be instantiated with the CacheManager.Get<T> method.
Constructors
CacheBaseV2()
Default constructor for CacheBase
Declaration
protected CacheBaseV2()
Remarks
Classes inheriting this class should only be instantiated through the CacheManager.Get<T> method.
Exceptions
Type | Condition |
---|---|
SecurityException | This exception will be thrown if not above elements in the call stack is saved with the SuperOffice strong name. |
Properties
Disposed
Indicates whether the cache is disposed/flushed. Cache data is still accessable, but might be out of date.
Declaration
public bool Disposed { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
This flag is useful for debugging if we suddenly end up with an out of date cacehe and don't know why. So please don't remove this property even if it isn't in use anywhere.
TableNames
Gets the names of the table data that are cached in this cache. When these tables are updated the cache will be disposed so a new cache instance can take its place.
Declaration
protected abstract IEnumerable<string> TableNames { get; }
Property Value
Type | Description |
---|---|
IEnumerable<string> |
Remarks
Implement this class if you want to implement a cache within NetServer. Classes implementing this class should always be instantiated with the CacheManager.Get<T> method.
Methods
BeginDisableAutoUpdate()
Base class for caches.
Declaration
public IAsyncDisposable BeginDisableAutoUpdate()
Returns
Type | Description |
---|---|
IAsyncDisposable |
Remarks
Implement this class if you want to implement a cache within NetServer. Classes implementing this class should always be instantiated with the CacheManager.Get<T> method.
InstanceDispose()
Dispose of the cache. NOTE - the data in the cache should be left untouched
Declaration
public void InstanceDispose()
Remarks
Someone may be using the cache, even if it is being 'disposed' here. The meaning of dispose is 'this is no longer
the current instance of this cache'; so it's taken out of all the lifetime and notification mechanisms. However,
the principle of immutability means that the content of the cache should not be changed.
Clients that do SomeCache.GetCurrent().GetSomething() may well have a thread in the GetSomething method and
it would be very bad to interrupt that. There the cleanup of the cache object is left to the garbage collector,
who knows when it is actually unreferenced. And once that happens no-one can get hold of it again.
IsCacheInvalidatedAsync(string, int, PrivateSave, CancellationToken)
Determine if the change made the cache invalid.
Declaration
protected virtual Task<bool> IsCacheInvalidatedAsync(string tableName, int primaryKey, PrivateSave save, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | tableName | |
int | primaryKey | Primary key of the record being changed. |
PrivateSave | save | The SQL statement generating the change |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<bool> |
Remarks
By default, any change to a cached table will cause invalidation, but a cache may have a more discerning opinion; if so then implement this method.
Load()
Loads the cache data
Declaration
protected void Load()
Remarks
Implement this class if you want to implement a cache within NetServer. Classes implementing this class should always be instantiated with the CacheManager.Get<T> method.
LoadAsync(CancellationToken)
Loads the cache data
Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
protected Task LoadAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
Remarks
Implement this class if you want to implement a cache within NetServer. Classes implementing this class should always be instantiated with the CacheManager.Get<T> method.
OnLoad()
Base class for caches.
Declaration
protected abstract void OnLoad()
Remarks
Implement this class if you want to implement a cache within NetServer. Classes implementing this class should always be instantiated with the CacheManager.Get<T> method.
OnLoadAsync(CancellationToken)
Base class for caches.
Declaration
protected abstract Task OnLoadAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
Remarks
Implement this class if you want to implement a cache within NetServer. Classes implementing this class should always be instantiated with the CacheManager.Get<T> method.