Home > Software engineering >  Getting error while integrating Redis with ASP.Net core 6: Wrong number of args calling Redis comman
Getting error while integrating Redis with ASP.Net core 6: Wrong number of args calling Redis comman

Time:07-08

I was trying to implement distributed caching using Redis Cache in ASP.Net core 6. Followed the below urls: https://www.c-sharpcorner.com/article/distributed-redis-caching-in-asp-net-core/ https://medium.com/net-core/in-memory-distributed-redis-caching-in-asp-net-core-62fb33925818

But getting this exception on SetAsync() command -> "error_description": "ERR Error running script (call to f_3915ee22fda531a1d5661f2523d0443fd35ff0a4): @user_script:2: @user_script: 2: Wrong number of args calling Redis command From Lua script "

1)Installed Redis(3.0.504) locally ( https://github.com/MicrosoftArchive/redis/releases) 2)I have installed Microsoft.Extensions.Caching.StackExchangeRedis package 3)My AddAsync method:

public async Task AddAsync(string key, byte[] value)
{
    // Setting up the cache options
    DistributedCacheEntryOptions options = new DistributedCacheEntryOptions()
        .SetAbsoluteExpiration(DateTime.Now.AddMinutes(5))
        .SetSlidingExpiration(TimeSpan.FromMinutes(3));

    await _distributedCache.SetAsync(key, value, options, token);
}

CodePudding user response:

The issue is related to the version of Microsoft.Extensions.Caching.StackExchangeRedis.

Github Issues:

Receiving error when invoking IDistributedCache.SetAsync: Wrong number of args calling Redis command From Lua script #39879

Summary:

We can reproduce the issue easily and the good news the latest version has fixed this issue.

So I suggest you can use .net 6 and Microsoft.Extensions.Caching.StackExchangeRedis 6.0.2.

  • Related