Skip to content
💥 EasyCaching is an open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easier!
Branch: master
Clone or download
catcherwong Merge pull request #102 from dotnetcore/dev
Bug fixed and write document
Latest commit b49c92b Mar 28, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
build 💡 Documenting source code Mar 27, 2019
docs 📝 Update In-Memory.md Mar 27, 2019
media 🍱 Add hybrid_details.png Feb 9, 2019
sample Fix configuration error under multi-instance. Mar 14, 2019
src 💡 Documenting source code Mar 27, 2019
test Fix bug of HybridCachingProvider Mar 26, 2019
tools 💚 Redis CI Jan 27, 2019
.gitignore
.travis.yml 💚 Fixing Unstable CI Build. Dec 13, 2018
EasyCaching.sln
ISSUE_TEMPLATE.md 📝 Create ISSUE_TEMPLATE.md Mar 29, 2018
LICENSE 📄 Update License(.NET Core Community and Contributors) [ci skip] Feb 12, 2019
README.md 📝 Update README and add todolist Mar 25, 2019
ToDoList.md 📝 Update README and add todolist Mar 25, 2019
appveyor.yml 💚 Redis CI Jan 27, 2019
mkdocs.yml 💬 Add doc for CSRedis provider Feb 17, 2019

README.md

EasyCaching is an open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easier!

Coverage Status Member project of .NET Core Community GitHub license FOSSA Status

CI Build Status

Platform Build Server Master Status Dev Status
AppVeyor Windows/Linux Build status Build status
Travis Linux/OSX Build Status Build Status

Nuget Packages

Package Name Version Downloads
EasyCaching.Core
EasyCaching.InMemory
EasyCaching.Redis
EasyCaching.Memcached
EasyCaching.SQLite
EasyCaching.HybridCache
EasyCaching.CSRedis
EasyCaching.Interceptor.Castle
EasyCaching.Interceptor.AspectCore
EasyCaching.Serialization.MessagePack
EasyCaching.Serialization.Json
EasyCaching.Serialization.Protobuf
EasyCaching.Bus.RabbitMQ
EasyCaching.Bus.Redis
EasyCaching.Bus.CSRedis
EasyCaching.ResponseCaching

Basic Usages

Step 1 : Install the package

Choose one kinds of caching type that you needs and install it via Nuget.

Install-Package EasyCaching.InMemory
Install-Package EasyCaching.Redis
Install-Package EasyCaching.SQLite
Install-Package EasyCaching.Memcached

Step 2 : Config in your Startup class

Different types of caching hvae their own way to config.

Here is a sample show you how to config.

public class Startup
{
    //...
    
    public void ConfigureServices(IServiceCollection services)
    {
        //configuration
        services.AddEasyCaching(option=> 
        {
            //use memory cache that named default
            option.UseInMemory("default");

            //use redis cache that named redis1
            option.UseRedis(config => 
            {
                config.DBConfig.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6379));
            }, "redis1")
            .WithMessagePack()//with messagepack serialization
            ;            
        });    
    }    
}

Step 3 : Write code in you controller

[Route("api/[controller]")]
public class ValuesController : Controller
{
    // //when using single provider
    // private readonly IEasyCachingProvider _provider;
    //when using multiple provider
    private readonly IEasyCachingProviderFactory _factory;

    public ValuesController(
        //IEasyCachingProvider provider, 
        IEasyCachingProviderFactory factory
        )
    {
        //this._provider = provider;
        this._factory = factory;
    }

    [HttpGet]
    public string Handle()
    {
        //var provider = _provider;
        //get the provider from factory with its name
        var provider = _factory.GetCachingProvider("redis1");    

        //Set
        provider.Set("demo", "123", TimeSpan.FromMinutes(1));
            
        //Set Async
        await provider.SetAsync("demo", "123", TimeSpan.FromMinutes(1));                  
    }
}

Documentation

For more helpful information about EasyCaching, please click here for EasyCaching's documentation.

Extension Libs

Examples

See sample

Todo List

See ToDo List

Contributing

Pull requests, issues and commentary!

License

FOSSA Status

You can’t perform that action at this time.