Hi, this library contains more than one cache provider.
Thus, you can easily change the provider in your applications without re-implementation.
If you liked the project or if EasyCache helped you, please give a star.
EasyCache includes one more than cache provider. Choose any.
Install EasyCache.Memory
from Nuget Package
Add services.AddEasyMemoryCache()
in startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddEasyMemoryCache(); <-- Initialize EasyCache for MemoryCache
}
after get IEasCacheService
from dependency injection.
private readonly IEasyCacheService easyCacheService;
public DefaultController(IEasyCacheService easyCacheService)
{
this.easyCacheService = easyCacheService;
}
Install EasyCache.Redis
from Nuget Package
Add services.AddEasyRedisCache()
in startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddEasyRedisCache(options=>
{
options.Configuration = "localhost";
options.InstanceName = GetType().Assembly.GetName().Name
}); <-- Initialize EasyCache for Redis
}
after get IEasCacheService
from dependency injection.
private readonly IEasyCacheService easyCacheService;
public DefaultController(IEasyCacheService easyCacheService)
{
this.easyCacheService = easyCacheService;
}
Install EasyCache.MemCache
from Nuget Package
Add services.AddEasyRedisCache()
in startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddEasyMemCache(options=>options.AddServer("localhost",11211)); <-- Initialize EasyCache for MemCache
}
after get IEasCacheService
from dependency injection.
private readonly IEasyCacheService easyCacheService;
public DefaultController(IEasyCacheService easyCacheService)
{
this.easyCacheService = easyCacheService;
}
See for more information Wiki
If you are having problems, please let us know by raising a new issue.