Skip to content

RedisDatabaseProvider can't re-connect #303

@steelmaker

Description

@steelmaker

Description

I used asp.net core 3.1 application with EasyCaching.Redis 1.2.1
EasyCaching.Redis.RedisDatabaseProvider works badlly if redis not available in first request.

Steps to Reproduce

  1. stop redis
  2. run application
  3. request to cache (easycaching) -> exception
  4. start redis
  5. request to cache -> exception

Related code

for my opinion problem here

private readonly Lazy<ConnectionMultiplexer> _connectionMultiplexer;

works correctly if implement like this

private Lazy<ConnectionMultiplexer> _connectionMultiplexer;
...
public IDatabase GetDatabase()
{
    try
    {
        return _connectionMultiplexer.Value.GetDatabase();
    }
    catch (Exception)
    {
        _connectionMultiplexer = new Lazy<ConnectionMultiplexer>(CreateConnectionMultiplexer);
        throw;
    }
}

Expected behavior: [What you expected to happen]

I expected cache will be work if redis available

Actual behavior: [What actually happened]

cache response exception

Specifications

  • Provider : EasyCaching.Redis 1.2.1
  • Interceptor : asp.net core 3.1
  • Serializer : msgpack
  • System : window 10

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions