Primary Data Caching Provider
Last updated
Was this helpful?
Last updated
Was this helpful?
IDataCachingService
in assembly SanteDB.Core.Api version 3.0.1980.0
Defines a service which can be used by callers to store full RIM objects in a transient cache.
The data caching service is primarily used to store fully loaded objects from the database. This loading into the cache reduces the load on the persistence layer of the SanteDB host context. The data persistence layers themselves will use implementations of this class to prevent re-loading of data to/from the disk system. The process on a read is generally:
Check the cache service to determine if the data has already been loaded
If not found in cache load the data from disk / database
Add the object to the cache
Of course, keeping the cache service in a consistent state is tantamount to the reliable functioning of SanteDB, this means that any update, delete or create on an object that already exists in cache results in its eviction from the cache via the ) method.
Added
EventHandler<DataCacheEventArgs>
Fired after an object has successfully been committed to the cache
Updated
EventHandler<DataCacheEventArgs>
Fired after an object has successfully been updated within the cache
Removed
EventHandler<DataCacheEventArgs>
Fired after an object has successfully been evicted from cache
Size
Int64
R
Gets the current size of the cache in objects
GetCacheItem
TData
Guid key
Gets the cache item specified by returning it as a casted instance of . Returning the default of if the object doesn't exist or if the object is the wrong type.
GetCacheItem
IdentifiedData
Guid key
Gets the cache item specified by regardless of the type of data
Add
void
IdentifiedData data
Adds to the cache
Remove
void
Guid key
Removes/evicts an object with identifier from the cache
Remove
void
IdentifiedData data
Removes/evicts an object with identifier from the cache
Clear
void
none
TODO
Exists
Boolean
Guid id
Returns true if the specified cache item exists
It does not require the setup of a third-party service to operate
The cache objects are directly accessed and not serialized
The cache objects are protected within the host process memory
The access is very fast - there is no interconnection with another process
This cache service should only be used in cases when there is a single SanteDB server and there is no need for sharing cache objects between application services.
The use of the .NET XML serializer over the Newtonsoft JSON serializer for caching was chosen since the serializer operates on streams (saves string conversions) and pre-compiles the serialization classes on .NET Framework implementations (Mono implementations use relfection)
The caching data is stored in database 1 of the REDIS server.
Implementation of the which uses the in-process memory to cache objects
The memory cache service uses the class as a backing cache for the SanteDB host instance. This caching provider provides benefits over a common, shared cache like REDIS in that:
This class uses the TTL setting from the to determine the length of time that cache entries are valid
An implementation of the which uses REDIS
This implementation of the caching service uses the XMLSerializer in .NET to serialize any object passed in via the ) method. The data is then compressed (if configured) and sent to the configured REDIS server.