Back to rankings

dotnetcore/EasyCaching

C#

:boom: 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!

cachingmemory-cachedistributed-cacheaspnetcoreredismemcachedsqlitehybrid-cacheinterceptorcache
Star Growth
Stars
2.1k
Forks
337
Weekly Growth
Issues
44
1k2k
Jan 2018Nov 2020Sep 2023Jul 2026
README

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 easily!

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

CI Build Status

Platform Build Server Master Status Dev Status
Github Action Linux/Windows Build&Test Build&Test

Nuget Packages

Package Name Version Downloads
EasyCaching.Core
EasyCaching.InMemory
EasyCaching.Redis
EasyCaching.Memcached
EasyCaching.SQLite
EasyCaching.HybridCache
EasyCaching.CSRedis
EasyCaching.FreeRedis
EasyCaching.FasterKv
EasyCaching.Disk
EasyCaching.LiteDB
EasyCaching.Interceptor.Castle
EasyCaching.Interceptor.AspectCore
EasyCaching.Serialization.MessagePack
EasyCaching.Serialization.Json
EasyCaching.Serialization.SystemTextJson
EasyCaching.Serialization.Protobuf
EasyCaching.Serialization.MemoryPack
EasyCaching.Bus.RabbitMQ
EasyCaching.Bus.RabbitMQStream
EasyCaching.Bus.Redis
EasyCaching.Bus.CSRedis
EasyCaching.Bus.ConfluentKafka
EasyCaching.Bus.Zookeeper
EasyCaching.ResponseCaching

Basic Usages

Step 1 : Install the package

Choose caching provider that you need and install it via Nuget.

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

Step 2 : Configure Startup class

Each caching provider has it's own configuration options.

Here is a sample configuration for InMemory and Redis caching provider.

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

            // // use memory cache with your own configuration
            // options.UseInMemory(config => 
            // {
            //     config.DBConfig = new InMemoryCachingOptions
            //     {
            //         // scan time, default value is 60s
            //         ExpirationScanFrequency = 60, 
            //         // total count of cache items, default value is 10000
            //         SizeLimit = 100 
            //     };
            //     // the max random second will be added to cache's expiration, default value is 120
            //     config.MaxRdSecond = 120;
            //     // whether enable logging, default is false
            //     config.EnableLogging = false;
            //     // mutex key's alive time(ms), default is 5000
            //     config.LockMs = 5000;
            //     // when mutex key alive, it will sleep some time, default is 300
            //     config.SleepMs = 300;
            // }, "m2");

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

Step 3 : Write code in your 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

Detailed EasyCaching documentation can be found here.

Extension Libs

Package Name Downloads Description
EasyCaching.Extensions.EasyCompressor Compress your cache objects to speedup transferring data over network, reduce bandwidth usage, and memory usage of cache server
EasyCaching.Extensions EasyCaching integration for CAP, WebApiClient, IDistributedCache, ...

Examples

See sample

Todo List

See ToDo List

Contributing

Pull requests, issues and commentary!

License

FOSSA Status

Related repositories
redis/redis

For developers, who are building real-time data-driven applications, Redis is the preferred, fastest, and most feature-rich cache, data structure server, and document and vector query engine.

COtherdatabasekey-value
redis.io
75.6k24.7k
dagger/dagger

Automation engine to build, test and ship any codebase. Runs locally, in CI, or directly in the cloud

GoGo ModulesApache License 2.0ci-cdcontainers
dagger.io
16.1k906
allegro/bigcache

Efficient cache for gigabytes of data written in Go.

GoGo ModulesApache License 2.0cacheperformance
allegro.tech/2016/03/writing-fast-cache-service-in-go.html
8.1k610
haproxy/haproxy

HAProxy Load Balancer's development branch (mirror of git.haproxy.org)

COtherhaproxyload-balancer
git.haproxy.org
6.7k947
hazelcast/hazelcast

Hazelcast is a unified real-time data platform combining stream processing with a fast data store, allowing customers to act instantly on data-in-motion for real-time insights.

JavaMavenOtherjavahazelcast
hazelcast.com
6.6k1.9k
isaacs/node-lru-cache

A fast cache that automatically deletes the least recently used items

JavaScriptnpmBlue Oak Model License 1.0.0cachecaching
isaacs.github.io/node-lru-cache/
5.9k368
readysettech/readyset

Readyset is a MySQL and Postgres wire-compatible caching layer that sits in front of existing databases to speed up queries and horizontally scale read throughput. Under the hood, ReadySet caches the results of cached select statements and incrementally updates these results over time as the underlying data changes.

Rustcrates.ioOthercachingcaching-proxy
readyset.io
5.3k161
NekR/offline-plugin

Offline plugin (ServiceWorker, AppCache) for webpack (https://webpack.js.org/)

JavaScriptnpmMIT Licenseservice-workerappcache
4.5k288
joblib/joblib

Computing with Python functions.

PythonPyPIBSD 3-Clause "New" or "Revised" Licensepythonparallel-computing
joblib.readthedocs.org
4.4k468
symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

PHPPackagistMIT Licensephpsymfony
symfony.com/cache
4.2k65
varnishcache/varnish-cache

Varnish Cache source code repository

COtherhttpcaching
varnish-cache.org
4k394
ZiggyCreatures/FusionCache

FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.

C#MIT Licensecachingcache
3.8k198