Skip to content

furkandeveloper/EasyCache

Repository files navigation

CodeFactor Nuget Nuget Nuget Nuget Nuget Nuget Nuget Nuget Maintainability License: MIT

EasyCache

Hi, this library contains more than one cache provider.

Thus, you can easily change the provider in your applications without re-implementation.

Give a Star 🌟

If you liked the project or if EasyCache helped you, please give a star.

How to use EasyCache?

EasyCache includes one more than cache provider. Choose any.

EasyCache for MemoryCache

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;
}

EasyCache for Redis

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;
}

EasyCache for MemCache

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

Support

If you are having problems, please let us know by raising a new issue.


Alt

Star History

Star History Chart