Table of Contents

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

pattern string

The 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

key string

The identifier of the object to delete.

Returns

Task

A Task that represents the asynchronous delete operation.

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

key string

The identifier of the object to retrieve.

updateExpiration bool

Indicates 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 T if 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

key string

The unique identifier used to look up the stored object.

ttlOverride TimeSpan?

An optional time-to-live value that, when provided, overrides the default expiration for the entry.

updateExpiration bool

Indicates 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 null if 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

key string

The cache key used to identify the stored object.

factory Func<Task<T>>

The asynchronous function executed to produce the object when no cached value exists for the given key.

ttl TimeSpan?

The optional expiration period for the cached entry; if null, the default cache lifetime is applied.

cancellationToken CancellationToken

The 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

groupedField GroupedField

The grouped field used to categorize and identify the cached object.

patientId ObjectId

The identifier of the patient the object is associated with.

factory Func<Task<T>>

The asynchronous factory delegate invoked to produce the object when it is not found in the cache.

ttl TimeSpan?

The optional time-to-live duration applied to the cached entry.

cancellationToken CancellationToken

The 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

key string

The key associated with the value to retrieve or set.

loader Func<Task<string>>

The asynchronous function used to load the value.

ttl TimeSpan?

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

key string

The key used to look up the associated value.

Returns

string

The value associated with key, or null if 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

key string

The unique identifier used to store and later retrieve the object.

obj T

The object to store in the data store.

updateExpiration bool

Indicates whether the expiration time of the cached entry should be updated. Defaults to true.

Returns

Task

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

key string

The identifier used to store and retrieve the object.

obj T

The object to be stored.

ttlOverride TimeSpan?

An optional time-to-live value that overrides the default expiration period; null uses the default.

updateExpiration bool

A 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)

Parameters

key string

The identifier used to reference the value.

value string

The value intended to be associated with the key.