Loic.dotnetcore.EasyCaching 1.0.0

dotnet add package Loic.dotnetcore.EasyCaching --version 1.0.0
                    
NuGet\Install-Package Loic.dotnetcore.EasyCaching -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Loic.dotnetcore.EasyCaching" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Loic.dotnetcore.EasyCaching" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Loic.dotnetcore.EasyCaching" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Loic.dotnetcore.EasyCaching --version 1.0.0
                    
#r "nuget: Loic.dotnetcore.EasyCaching, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Loic.dotnetcore.EasyCaching@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Loic.dotnetcore.EasyCaching&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Loic.dotnetcore.EasyCaching&version=1.0.0
                    
Install as a Cake Tool

alternate text is missing from this package README image

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
AppVeyor Windows/Linux Build status Build status
Travis Linux/OSX Build Status Build Status

Nuget Packages

Package Name Version Downloads
EasyCaching.Core alternate text is missing from this package README image alternate text is missing from this package README image
EasyCaching.InMemory alternate text is missing from this package README image alternate text is missing from this package README image
EasyCaching.Redis alternate text is missing from this package README image alternate text is missing from this package README image
EasyCaching.Memcached alternate text is missing from this package README image alternate text is missing from this package README image
EasyCaching.SQLite alternate text is missing from this package README image alternate text is missing from this package README image
EasyCaching.HybridCache alternate text is missing from this package README image alternate text is missing from this package README image
EasyCaching.CSRedis alternate text is missing from this package README image alternate text is missing from this package README image
EasyCaching.Interceptor.Castle alternate text is missing from this package README image alternate text is missing from this package README image
EasyCaching.Interceptor.AspectCore alternate text is missing from this package README image alternate text is missing from this package README image
EasyCaching.Serialization.MessagePack alternate text is missing from this package README image alternate text is missing from this package README image
EasyCaching.Serialization.Json alternate text is missing from this package README image alternate text is missing from this package README image
EasyCaching.Serialization.Protobuf alternate text is missing from this package README image alternate text is missing from this package README image
EasyCaching.Bus.RabbitMQ alternate text is missing from this package README image alternate text is missing from this package README image
EasyCaching.Bus.Redis alternate text is missing from this package README image alternate text is missing from this package README image
EasyCaching.Bus.CSRedis alternate text is missing from this package README image alternate text is missing from this package README image
EasyCaching.ResponseCaching alternate text is missing from this package README image alternate text is missing from this package README image
EasyCaching.Disk alternate text is missing from this package README image alternate text is missing from this package README image
EasyCaching.LiteDB alternate text is missing from this package README image alternate text is missing from this package README image
EasyCaching.Serialization.SystemTextJson alternate text is missing from this package README image alternate text is missing from this package README image

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

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
            .UseRedisLock()//with distributed lock
            ;            
        });    
    }    
}

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

Examples

See sample

Todo List

See ToDo List

Contributing

Pull requests, issues and commentary!

Also can join our QQ group.

alternate text is missing from this package README image

License

FOSSA Status

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net5.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 0 7/31/2021