-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresfeature-cachingIncludes: StackExchangeRedis and SqlServer distributed cachesIncludes: StackExchangeRedis and SqlServer distributed caches
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Receiving an error when invoking IDistributedCache.SetAsync, I understand there is a fix and want to confirm if its been released: #38927
The project is a .Net6 project using Microsoft.Extensions.Caching.StackExchangeRedis 6.0.1 and Redis Server 6.2.6. The error is as follows:
StackExchange.Redis.RedisServerException
HResult=0x80131500
Message=ERR Error running script (call to f_3915ee22fda531a1d5661f2523d0443fd35ff0a4): @user_script:2: @user_script: 2: Wrong number of args calling Redis command From Lua script
Source=System.Private.CoreLib
StackTrace:
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.<SetAsync>d__15.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at SudokuCollective.Data.Resiliency.CacheFactory.<GetByUserNameWithCacheAsync>d__17.MoveNext() in C:\Users\Joe\Source\VS2022\SudokuCollective\SudokuCollective.Data\Resiliency\CacheFactory.cs:line 1034
This exception was originally thrown at this call stack:
[External Code]
SudokuCollective.Data.Resiliency.CacheFactory.GetByUserNameWithCacheAsync(SudokuCollective.Core.Interfaces.Repositories.IUsersRepository<SudokuCollective.Core.Models.User>, Microsoft.Extensions.Caching.Distributed.IDistributedCache, string, System.DateTime, string, string, SudokuCollective.Core.Interfaces.Models.DomainObjects.Params.IResult) in CacheFactory.cs
For the above noted branch I note it's been merged but wanted to confirmed if it's been released. If release is pending is there an ETA on the release? This is currently a breaking change for this project.
Expected Behavior
The object should be serialized and sent to the redis cache.
Steps To Reproduce
internal static async Task<Tuple<IRepositoryResponse, IResult>> GetByUserNameWithCacheAsync(
IUsersRepository<User> repo,
IDistributedCache cache,
string cacheKey,
DateTime expiration,
string username,
string license = null,
IResult result = null)
{
try
{
IRepositoryResponse response;
var cachedItem = await cache.GetAsync(cacheKey);
if (cachedItem != null)
{
var serializedItem = Encoding.UTF8.GetString(cachedItem);
response = new RepositoryResponse
{
Success = true,
Object = JsonSerializer.Deserialize<User>(serializedItem)
};
if (result != null)
{
result.IsFromCache = true;
}
}
else
{
response = await repo.GetByUserName(username);
if (response.Success && response.Object != null)
{
var serializedItem = JsonSerializer.Serialize<User>(
(User)response.Object,
new JsonSerializerOptions
{
ReferenceHandler = ReferenceHandler.Preserve
});
var encodedItem = Encoding.UTF8.GetBytes(serializedItem);
var options = new DistributedCacheEntryOptions()
.SetAbsoluteExpiration(expiration);
// Error is being thrown here...
await cache.SetAsync(
cacheKey,
encodedItem,
options);
// Error is being thrown here...
await cache.SetAsync(
string.Format(CacheKeys.GetUserCacheKey, response.Object.Id, license),
encodedItem,
options);
}
}
return new Tuple<IRepositoryResponse, IResult>(response, result);
}
catch
{
throw;
}
}
Exceptions (if any)
StackExchange.Redis.RedisServerException
HResult=0x80131500
Message=ERR Error running script (call to f_3915ee22fda531a1d5661f2523d0443fd35ff0a4): @user_script:2: @user_script: 2: Wrong number of args calling Redis command From Lua script
Source=System.Private.CoreLib
StackTrace:
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.<SetAsync>d__15.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at SudokuCollective.Data.Resiliency.CacheFactory.<GetByUserNameWithCacheAsync>d__17.MoveNext() in C:\Users\Joe\Source\VS2022\SudokuCollective\SudokuCollective.Data\Resiliency\CacheFactory.cs:line 1034
This exception was originally thrown at this call stack:
[External Code]
SudokuCollective.Data.Resiliency.CacheFactory.GetByUserNameWithCacheAsync(SudokuCollective.Core.Interfaces.Repositories.IUsersRepository<SudokuCollective.Core.Models.User>, Microsoft.Extensions.Caching.Distributed.IDistributedCache, string, System.DateTime, string, string, SudokuCollective.Core.Interfaces.Models.DomainObjects.Params.IResult) in CacheFactory.cs
.NET Version
6.0
Anything else?
No response
Metadata
Metadata
Assignees
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresfeature-cachingIncludes: StackExchangeRedis and SqlServer distributed cachesIncludes: StackExchangeRedis and SqlServer distributed caches