-
Notifications
You must be signed in to change notification settings - Fork 840
Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
The documentation for HybridCache's MaximumPayloadBytes option indicates:
The maximum size of cache items; attempts to store values over this size will be logged and the value will not be stored in cache.
This can be seen in the XML comments and here.
However, in practice what I am seeing is that an exception is thrown (rather than logging an error, not caching the entry, and ideally still returning the data that was to be cached).
Expected Behavior
If the payload exceeds configured limits, log an error, do not cache, and return the payload (per the docs).
Steps To Reproduce
Attempt to cache more than 1MB of data using HybridCache.
Exceptions (if any)
InvalidOperationException: Max length exceeded
Microsoft.Extensions.Caching.Hybrid.Internal.RecyclableArrayBufferWriter<T>.<Advance>g__ThrowQuota|13_1()
Microsoft.Extensions.Caching.Hybrid.Internal.RecyclableArrayBufferWriter<T>.Advance(int count)
System.Text.Json.Utf8JsonWriter.Flush()
System.Text.Json.Utf8JsonWriter.Dispose()
Microsoft.Extensions.Caching.Hybrid.Internal.DefaultJsonSerializerFactory+DefaultJsonSerializer<T>.Microsoft.Extensions.Caching.Hybrid.IHybridCacheSerializer<T>.Serialize(T value, IBufferWriter<byte> target)
Microsoft.Extensions.Caching.Hybrid.Internal.DefaultHybridCache+MutableCacheItem<T>.SetValue(T value, IHybridCacheSerializer<T> serializer, int maxLength)
Microsoft.Extensions.Caching.Hybrid.Internal.DefaultHybridCache+StampedeState<TState, T>.SetResult(T value)
Microsoft.Extensions.Caching.Hybrid.Internal.DefaultHybridCache+StampedeState<TState, T>.BackgroundFetchAsync()
Microsoft.Extensions.Caching.Hybrid.Internal.DefaultHybridCache+StampedeState<TState, T>.<JoinAsync>g__WithCancellation|24_0(StampedeState<TState, T> stampede, CancellationToken token)
System.Runtime.CompilerServices.ValueTaskAwaiter<TResult>.GetResult()
.NET Version
9.0.100-rc.1.24452.12
Anything else?
No response
bdukes, Aetheron and johnricketts