Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HybridCache MaximumPayloadBytes not operating per documentation #5432

Open
1 task done
nwoolls opened this issue Sep 17, 2024 · 2 comments · May be fixed by #5467
Open
1 task done

HybridCache MaximumPayloadBytes not operating per documentation #5432

nwoolls opened this issue Sep 17, 2024 · 2 comments · May be fixed by #5467

Comments

@nwoolls
Copy link

nwoolls commented Sep 17, 2024

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

@BrennanConroy
Copy link
Member

HybridCache lives in dotnet/extensions now. Moving the issue.

@BrennanConroy BrennanConroy transferred this issue from dotnet/aspnetcore Sep 17, 2024
@mgravell
Copy link
Member

Yep, fair. Will fix ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants