Class CacheBaseV2
Base class for caches.
Inheritance
Inherited Members
Namespace: SuperOffice.Data.Cache
Assembly: SoDataBase.dll
Syntax
public abstract class CacheBaseV2 : IFlushableV2, IDisposable
Remarks
Implement this class if you want to implement a cache within NetServer. Classes implementing this class should always be instantiated with the Get<T>() method.
Constructors
CacheBaseV2()
Default constructor for CacheBase
Declaration
protected CacheBaseV2()
Remarks
Classes inheriting this class should only be instantiated through the 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 Get<T>() method.
Methods
BeginDisableAutoUpdate()
Base class for caches.
Declaration
public CacheManager.DisableAutoUpdateScope BeginDisableAutoUpdate()
Returns
Type | Description |
---|---|
CacheManager.DisableAutoUpdateScope |
Remarks
Implement this class if you want to implement a cache within NetServer. Classes implementing this class should always be instantiated with the Get<T>() method.
Dispose()
Dispose of the cache. NOTE - the data in the cache should be left untouched
Declaration
public void Dispose()
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.
Flush()
Releases the cache instance for the GC to clean up, next cache fetched will be a new instance with new data loaded.
Declaration
public void Flush()
Remarks
Implement this class if you want to implement a cache within NetServer. Classes implementing this class should always be instantiated with the Get<T>() method.
GetCurrent<T>()
Obtain an instance of the cache
Declaration
public static T GetCurrent<T>() where T : CacheBaseV2
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |
Remarks
Implement this class if you want to implement a cache within NetServer. Classes implementing this class should always be instantiated with the Get<T>() method.
IsCacheInvalidated(string, int, PrivateSave)
Determine if the change made the cache invalid.
Declaration
protected virtual bool IsCacheInvalidated(string tableName, int primaryKey, PrivateSave save)
Parameters
Type | Name | Description |
---|---|---|
string | tableName | |
int | primaryKey | Primary key of the record being changed. |
PrivateSave | save | The SQL statement generating the change |
Returns
Type | Description |
---|---|
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 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 Get<T>() method.