'.net 6 and Redis cache integration using sets , hashes
.net 6 and Redis cache integration using sets , hashes. Please provide source code for this. Use latest stack exchange library.
Solution 1:[1]
Here is a simple save demo, you can take a look:
Program.cs:
builder.Services.AddStackExchangeRedisCache(options => {
options.Configuration = "127.0.0.1:6379";
});
builder.Services.AddSession();
app.UseSession();
Controller:
[ApiController]
public class TestController : Controller
{
private readonly IDistributedCache _distributedCache;
public TestController(IDistributedCache distributedCache)
{
_distributedCache = distributedCache;
}
[HttpGet]
[Route("test")]
public void Test()
{
const string key = "message";
const string value = "hello";
_distributedCache.SetString(key, value);
}
}
Result:
For more examples, you can refer to this article?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tupac |

