From de07db3770b871b571337504e45ccde4d5a75638 Mon Sep 17 00:00:00 2001 From: Marc Gravell <marc.gravell@gmail.com> Date: Thu, 1 Feb 2024 15:57:01 +0000 Subject: [PATCH] updates --- .../Caching/src/DistributedCacheServiceExtensions.cs | 1 + src/Caching/Caching/src/DistributedCacheT.cs | 2 ++ src/Caching/Caching/src/IBufferDistributedCache.cs | 7 ++++++- src/Caching/Caching/src/IDistributedCacheT.cs | 2 ++ src/Caching/Caching/src/PublicAPI.Unshipped.txt | 6 ++++++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Caching/Caching/src/DistributedCacheServiceExtensions.cs b/src/Caching/Caching/src/DistributedCacheServiceExtensions.cs index 46cee5a89f4d..b0aecd365cb6 100644 --- a/src/Caching/Caching/src/DistributedCacheServiceExtensions.cs +++ b/src/Caching/Caching/src/DistributedCacheServiceExtensions.cs @@ -29,5 +29,6 @@ public static IServiceCollection AddTypedDistributedCache(this IServiceCollectio public sealed class TypedDistributedCacheOptions { + // TBD } diff --git a/src/Caching/Caching/src/DistributedCacheT.cs b/src/Caching/Caching/src/DistributedCacheT.cs index 2b01d777cb17..047b21879225 100644 --- a/src/Caching/Caching/src/DistributedCacheT.cs +++ b/src/Caching/Caching/src/DistributedCacheT.cs @@ -36,6 +36,8 @@ public ValueTask<T> GetAsync<TState>(string key, TState state, Func<TState, Canc } + ValueTask IDistributedCache<T>.RefreshAsync(string key, CancellationToken cancellationToken) => new(_backend.RefreshAsync(key, cancellationToken)); + private ValueTask<T> GetBufferedBackendAsync<TState>(string key, TState state, Func<TState, CancellationToken, ValueTask<T>> callback, DistributedCacheEntryOptions? options, CancellationToken cancellationToken) { var buffer = new RecyclableArrayBufferWriter<byte>(); diff --git a/src/Caching/Caching/src/IBufferDistributedCache.cs b/src/Caching/Caching/src/IBufferDistributedCache.cs index cb4715510269..4eafa9837945 100644 --- a/src/Caching/Caching/src/IBufferDistributedCache.cs +++ b/src/Caching/Caching/src/IBufferDistributedCache.cs @@ -4,8 +4,13 @@ using System.Buffers; namespace Microsoft.Extensions.Caching.Distributed; -interface IBufferDistributedCache : IDistributedCache +public interface IBufferDistributedCache : IDistributedCache { ValueTask<bool> TryGetAsync(string key, IBufferWriter<byte> destination, CancellationToken cancellationToken); ValueTask SetAsync(string key, ReadOnlySequence<byte> value, DistributedCacheEntryOptions options, CancellationToken cancellationToken); } + +public interface IDistributedCacheInvalidation : IDistributedCache +{ + event Func<string, ValueTask> CacheKeyInvalidated; +} diff --git a/src/Caching/Caching/src/IDistributedCacheT.cs b/src/Caching/Caching/src/IDistributedCacheT.cs index 96b3e767e9b6..c7c5c97f4dfb 100644 --- a/src/Caching/Caching/src/IDistributedCacheT.cs +++ b/src/Caching/Caching/src/IDistributedCacheT.cs @@ -14,5 +14,7 @@ public interface IDistributedCache<T> ValueTask<T> GetAsync<TState>(string key, TState state, Func<TState, CancellationToken, ValueTask<T>> callback, DistributedCacheEntryOptions? options = null, CancellationToken cancellationToken = default); ValueTask RemoveAsync(string key, CancellationToken cancellationToken = default); + + ValueTask RefreshAsync(string key, CancellationToken cancellationToken = default); } diff --git a/src/Caching/Caching/src/PublicAPI.Unshipped.txt b/src/Caching/Caching/src/PublicAPI.Unshipped.txt index d748c9d7b012..d872595c0740 100644 --- a/src/Caching/Caching/src/PublicAPI.Unshipped.txt +++ b/src/Caching/Caching/src/PublicAPI.Unshipped.txt @@ -1,12 +1,18 @@ #nullable enable Microsoft.Extensions.Caching.Distributed.DistributedCacheServiceExtensions +Microsoft.Extensions.Caching.Distributed.IBufferDistributedCache +Microsoft.Extensions.Caching.Distributed.IBufferDistributedCache.SetAsync(string! key, System.Buffers.ReadOnlySequence<byte> value, Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions! options, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask +Microsoft.Extensions.Caching.Distributed.IBufferDistributedCache.TryGetAsync(string! key, System.Buffers.IBufferWriter<byte>! destination, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask<bool> Microsoft.Extensions.Caching.Distributed.ICacheSerializer<T> Microsoft.Extensions.Caching.Distributed.ICacheSerializer<T>.Deserialize(System.Buffers.ReadOnlySequence<byte> source) -> T Microsoft.Extensions.Caching.Distributed.ICacheSerializer<T>.Serialize(T value, System.Buffers.IBufferWriter<byte>! target) -> void Microsoft.Extensions.Caching.Distributed.IDistributedCache<T> Microsoft.Extensions.Caching.Distributed.IDistributedCache<T>.GetAsync(string! key, System.Func<System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<T>>! callback, Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<T> Microsoft.Extensions.Caching.Distributed.IDistributedCache<T>.GetAsync<TState>(string! key, TState state, System.Func<TState, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<T>>! callback, Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<T> +Microsoft.Extensions.Caching.Distributed.IDistributedCache<T>.RefreshAsync(string! key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask Microsoft.Extensions.Caching.Distributed.IDistributedCache<T>.RemoveAsync(string! key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask +Microsoft.Extensions.Caching.Distributed.IDistributedCacheInvalidation +Microsoft.Extensions.Caching.Distributed.IDistributedCacheInvalidation.CacheKeyInvalidated -> System.Func<string!, System.Threading.Tasks.ValueTask>! Microsoft.Extensions.Caching.Distributed.TypedDistributedCacheOptions Microsoft.Extensions.Caching.Distributed.TypedDistributedCacheOptions.TypedDistributedCacheOptions() -> void static Microsoft.Extensions.Caching.Distributed.DistributedCacheServiceExtensions.AddTypedDistributedCache(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!