27 lines
874 B
C#
27 lines
874 B
C#
using Microsoft.Extensions.Logging;
|
|
|
|
namespace StellaOps.Provcache.Valkey;
|
|
|
|
public sealed partial class ValkeyProvcacheStore
|
|
{
|
|
public async ValueTask<bool> InvalidateAsync(string veriKey, CancellationToken cancellationToken = default)
|
|
{
|
|
try
|
|
{
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
var db = await GetDatabaseAsync(cancellationToken).ConfigureAwait(false);
|
|
var redisKey = BuildKey(veriKey);
|
|
|
|
var deleted = await db.KeyDeleteAsync(redisKey).ConfigureAwait(false);
|
|
|
|
_logger.LogDebug("Invalidated cache entry for VeriKey {VeriKey}: {Deleted}", veriKey, deleted);
|
|
return deleted;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Error invalidating cache entry for VeriKey {VeriKey}", veriKey);
|
|
return false;
|
|
}
|
|
}
|
|
}
|