I'm using .Net core with StackExchangeRedis:
public void ConfigureServices(IServiceCollection services)
{
services.AddStackExchangeRedisCache(options =>
{
options.Configuration = "127.0.0.1:6379";
});
services.AddControllers();
}
Later I inject the service and testing it via set/get :
private readonly IDistributedCache _cache;
public MyRedisController(IDistributedCache cache)
{
_cache = cache;
}
[HttpGet]
public async Task<string> Get()
{
_cache.SetString("dd", "5");
var a = await _cache.GetStringAsync("dd"); //5
return a;
}
The problem is that when I try to get the value in redis-cli, I see :
127.0.0.1:6379> get "dd"
(error) WRONGTYPE Operation against a key holding the wrong kind of value
After investigating, I see that it's stored as a hash:
Question:
How can I use StackExchangeRedis to store simple string types without the hash type ? I want a simple string. (get/set)
ps
I know I can get the value via: hget "dd" data. But I'm after storing simple string type.
