Aspnetcore: DistributedRedisCache will write something extra into redis cache

Created on 7 Nov 2018  路  2Comments  路  Source: dotnet/aspnetcore

Document url

Distributed Redis Cache

Issue description

Add service in container:
```c#
public void ConfigureServices(IServiceCollection services)
{
services.AddDistributedRedisCache(opt => { opt.Configuration = "localhost:6379"; });
}

Set cache:
```c#
var info = new {Name = "xfh"};
var options = new DistributedCacheEntryOptions()
    .SetSlidingExpiration(TimeSpan.FromSeconds(20));
_cache.SetString(cacheKey, info.ToString(), options);

But,wirte into redis three keys and data type is hash instead of string

|key|value|
|---|---|
|absexp|-1|
|sldexp|200000000|
|data|{Name=xfh}|

In addition,IDistributedCache cannot use set,list,etc data struct of redis.

So,I don't think the IDistributedCache is suit for redis.,and I don't understand why design this interface.

Maybe I'm wrong,Thanks!

Software versions

  • .NET Core 2.0
  • Microsoft.Extensions.Caching.Redis 2.1.2

Most helpful comment

IDistributedCache is not intended as a means of interacting with arbitrary data in Redis. It's the other way around, Redis is used to store IDistributedCache data and state. You're welcome to store other data in Redis using Redis specific libraries.

All 2 comments

IDistributedCache is not intended as a means of interacting with arbitrary data in Redis. It's the other way around, Redis is used to store IDistributedCache data and state. You're welcome to store other data in Redis using Redis specific libraries.

OK,thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

guardrex picture guardrex  路  3Comments

ermithun picture ermithun  路  3Comments

githubgitgit picture githubgitgit  路  3Comments

FourLeafClover picture FourLeafClover  路  3Comments

rbanks54 picture rbanks54  路  3Comments