Doulex.DistributedCache is a extension library of Microsoft DistributedCache. It's provide some extensions methods like IOBjectCahce etc.
The library is under .NET Standard 2.0. It's compatible with .NET Core 2.0 and .NET Framework 4.6.1. DI is supported by Microsoft.Extensions.DependencyInjection.
Name | Version | Downloads |
---|---|---|
Doulex.DistributedCache |
add nuget package
Install-Package Doulex.DistributedCache
At your startup.cs, add the following code
public void ConfigureServices(IServiceCollection services)
{
services.AddDistributedMemoryCache()
// add the extension of distributed cache
services.AddDistributedCacheExtensions();
}
Injection IObjectCache
public class HomeController : Controller
{
private readonly IObjectCache<UserModel> _userModelCache;
public HomeController(IObjectCache<UserModel> userModelCache)
{
_userModelCache = userModelCache;
}
public IActionResult Index()
{
var userModel = _userModelCache.GetAsync("userModel");
return View(userModel);
}
}
Leave a comment on GitHub if you have any questions or suggestions.
Turn on the star if you like this project.
This project is licensed under the MIT License