Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

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

License

NotificationsYou must be signed in to change notification settings

dotnetcore/EasyCaching

Repository files navigation

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 StatusMember project of .NET Core CommunityGitHub licenseFOSSA Status

CI Build Status

PlatformBuild ServerMaster StatusDev Status
Github ActionLinux/WindowsBuild&TestBuild&Test

Nuget Packages

Package NameVersionDownloads
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.InMemoryInstall-Package EasyCaching.RedisInstall-Package EasyCaching.SQLiteInstall-Package EasyCaching.MemcachedInstall-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.

publicclassStartup{//...publicvoidConfigureServices(IServiceCollectionservices){//configurationservices.AddEasyCaching(options=>{//use memory cache that named defaultoptions.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 redis1options.UseRedis(config=>{config.DBConfig.Endpoints.Add(newServerEndPoint("127.0.0.1",6379));},"redis1").WithMessagePack()//with messagepack serialization;});}}

Step 3 : Write code in your controller

[Route("api/[controller]")]publicclassValuesController:Controller{// //when using single provider// private readonly IEasyCachingProvider _provider;//when using multiple providerprivatereadonlyIEasyCachingProviderFactory_factory;publicValuesController(//IEasyCachingProvider provider,IEasyCachingProviderFactoryfactory){//this._provider = provider;this._factory=factory;}[HttpGet]publicstringHandle(){//var provider = _provider;//get the provider from factory with its namevarprovider=_factory.GetCachingProvider("redis1");//Setprovider.Set("demo","123",TimeSpan.FromMinutes(1));//Set Asyncawaitprovider.SetAsync("demo","123",TimeSpan.FromMinutes(1));}}

Documentation

Detailed EasyCaching documentation can be foundhere.

Extension Libs

Package NameDownloadsDescription
EasyCaching.Extensions.EasyCompressorCompress your cache objects to speedup transferring data over network, reduce bandwidth usage, and memory usage of cache server
EasyCaching.ExtensionsEasyCaching integration for CAP, WebApiClient, IDistributedCache, ...

Examples

Seesample

Todo List

SeeToDo List

Contributing

Pull requests, issues and commentary!

License

FOSSA Status

About

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

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp