Class NoCacheService
- Namespace
- adas_core.Application.Services.Caching
- Assembly
- adas-core.Application.dll
Implementación nula de ICacheService. No almacena nada, no devuelve nada y no interfiere con el flujo. Se usa cuando el CacheMode es "None".
public class NoCacheService : ICacheService
- Inheritance
-
NoCacheService
- Implements
- Inherited Members
- Extension Methods
Methods
CleanCache()
Performs a cleanup operation on the cache. Currently, this method has no implementation and does not perform any cleanup actions.
public void CleanCache()
DeleteByPatternAsync(string)
Asynchronously deletes items matching the specified pattern and returns the number of items removed. This implementation is a stub that always returns 0, performing no actual deletion regardless of the provided pattern.
public Task<long> DeleteByPatternAsync(string pattern)
Parameters
patternstringThe pattern used to identify the items to delete.
Returns
- Task<long>
A Task<TResult> representing the asynchronous operation, with a result of 0 indicating that no items were deleted.
DeleteObjectAsync(string)
Asynchronously deletes the object identified by the specified key. The operation completes immediately without performing an actual deletion.
public Task DeleteObjectAsync(string key)
Parameters
keystringThe identifier of the object to delete.
Returns
GetObjectAsync<T>(string, bool)
Asynchronously retrieves an object of type T associated with the specified key.
public Task<T?> GetObjectAsync<T>(string key, bool updateExpiration = true)
Parameters
keystringThe identifier of the object to retrieve.
updateExpirationboolIndicates whether the expiration of the entry should be updated upon retrieval.
Returns
- Task<T>
A Task<TResult> that represents the asynchronous retrieval, containing the object associated with the key or the default value of
Tif not found.
Type Parameters
T
GetObjectAsync<T>(string, TimeSpan?, bool)
Asynchronously retrieves an object of type T associated with the specified key.
Supports an optional time-to-live override and an option to update the expiration of the stored entry.
public Task<T?> GetObjectAsync<T>(string key, TimeSpan? ttlOverride, bool updateExpiration)
Parameters
keystringThe unique identifier used to look up the stored object.
ttlOverrideTimeSpan?An optional time-to-live value that, when provided, overrides the default expiration for the entry.
updateExpirationboolIndicates whether the expiration of the entry should be refreshed upon a successful retrieval.
Returns
- Task<T>
A Task<TResult> that represents the asynchronous operation, containing the retrieved object or
nullif no value is found.
Type Parameters
T
GetOrSetObjectAsync<T>(string, Func<Task<T>>, TimeSpan?, CancellationToken)
Asynchronously retrieves an object associated with the specified key from the cache, or invokes the factory to create and cache a new one when the key is not found.
public Task<T> GetOrSetObjectAsync<T>(string key, Func<Task<T>> factory, TimeSpan? ttl = null, CancellationToken cancellationToken = default)
Parameters
keystringThe cache key used to identify the stored object.
factoryFunc<Task<T>>The asynchronous function executed to produce the object when no cached value exists for the given key.
ttlTimeSpan?The optional expiration period for the cached entry; if null, the default cache lifetime is applied.
cancellationTokenCancellationTokenThe token used to cancel the asynchronous operation.
Returns
- Task<T>
A task that resolves to the cached or newly created object of type
T.
Type Parameters
T
GetOrSetObjectAsync<T>(GroupedField, ObjectId, Func<Task<T>>, TimeSpan?, CancellationToken)
Asynchronously retrieves a cached object identified by the patient and grouped field, or creates and stores it via the supplied factory when no cached value exists.
public Task<T> GetOrSetObjectAsync<T>(GroupedField groupedField, ObjectId patientId, Func<Task<T>> factory, TimeSpan? ttl = null, CancellationToken cancellationToken = default)
Parameters
groupedFieldGroupedFieldThe grouped field used to categorize and identify the cached object.
patientIdObjectIdThe identifier of the patient the object is associated with.
factoryFunc<Task<T>>The asynchronous factory delegate invoked to produce the object when it is not found in the cache.
ttlTimeSpan?The optional time-to-live duration applied to the cached entry.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<T>
A task containing the cached or newly created object of type
T.
Type Parameters
T
GetOrSetValueAsync(string, Func<Task<string>>, TimeSpan?)
Asynchronously loads a value using the provided loader function.
public Task<string?> GetOrSetValueAsync(string key, Func<Task<string>> loader, TimeSpan? ttl = null)
Parameters
keystringThe key associated with the value to retrieve or set.
loaderFunc<Task<string>>The asynchronous function used to load the value.
ttlTimeSpan?An optional time-to-live duration for the value.
Returns
- Task<string>
A task that represents the asynchronous operation, containing the loaded value as a nullable string.
GetValue(string)
Retrieves the string value associated with the specified key.
Returns null when no value is found for the given key.
public string? GetValue(string key)
Parameters
keystringThe key used to look up the associated value.
Returns
- string
The value associated with
key, ornullif no value is found.
SetObjectAsync<T>(string, T, bool)
Asynchronously stores the specified object associated with the given key in the underlying data store.
When updateExpiration is true, the expiration of the entry is refreshed; otherwise the existing expiration is preserved.
public Task SetObjectAsync<T>(string key, T obj, bool updateExpiration = true)
Parameters
keystringThe unique identifier used to store and later retrieve the object.
objTThe object to store in the data store.
updateExpirationboolIndicates whether the expiration time of the cached entry should be updated. Defaults to true.
Returns
Type Parameters
T
SetObjectAsync<T>(string, T, TimeSpan?, bool)
Asynchronously stores an object associated with the specified key, optionally overriding the time-to-live and updating the expiration.
public Task SetObjectAsync<T>(string key, T obj, TimeSpan? ttlOverride, bool updateExpiration)
Parameters
keystringThe identifier used to store and retrieve the object.
objTThe object to be stored.
ttlOverrideTimeSpan?An optional time-to-live value that overrides the default expiration period;
nulluses the default.updateExpirationboolA value indicating whether the expiration time should be updated.
Returns
- Task
A task that represents the asynchronous set operation.
Type Parameters
T
SetValue(string, string)
Stub implementation that performs no action. Intended as a placeholder for storing a value associated with the specified key.
public void SetValue(string key, string value)