Servicestack.redis error

.net core 3.1 , servicestack.redis 5.9.2 , the below code works fine.

public partial class AppHost
{
    public void RegisterCache(Container container)
    {
        //4. Registering the session cache.
        container.Register<ICacheClient>(new MemoryCacheClient());
        
        container.Register<IRedisClientsManager>(
                   c => new PooledRedisClientManager($"password@127.0.0.1:1234"));
        container.Register(c =>
                    c.Resolve<IRedisClientsManager>().GetCacheClient());
    }
}
   public IActionResult Index()
        {
             var userName = "admin";
            using var authService = ResolveService<AuthenticateService>();
              authService.Authenticate(new Authenticate
             {
                provider = CredentialsAuthProvider.Name,
                UserName = userName,
              Password = userName + "123456",
               RememberMe = true  
           });
}

After upgrade to servicestack 5.10 , no code changes, works wrong
image

If I comment the below code , works fine , but become not used the redis , I think there are error in RedisClient, please help, thanks.

   //container.Register(c => c.Resolve<IRedisClientsManager>().GetCacheClient());

I don’t know what that error is, do you have a full Exception StackTrace?

It not show StackTrace. only show the above picture, and autostop the program. I think it is recursive execute one method. I had debug into SerivceStack.Redis, and always recursive execute below code.

In the ServiceStack.Redis Source Code, one file named RedisClientManagerCacheClient.Async.cs, It had the below code

        async Task<T> ICacheClientAsync.GetAsync<T>(string key, CancellationToken token)
        {
            await using var client = await redisManager.GetReadOnlyCacheClientAsync(token).ConfigureAwait(false);
            return await client.GetAsync<T>(key, token).ConfigureAwait(false);
        }

client.GetAsync(key, token).ConfigureAwait(false)

will call async Task ICacheClientAsync.GetAsync(string key, CancellationToken token) this method again, will recursive execute this method.

please checked it , thanks .

Yeah that was the issue which should now be resolved from this commit. This change is available from the latest v5.10.1 that’s now available on MyGet.

1 Like

Thanks, is there any plan to publish 5.10.2 ?

Yes as soon as all current issues are resolved I’ll push out a new release.

This fix is now available from v5.10.2 on NuGet.