五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

一個.Net Core開源緩存中間件,讓你更加簡單、方便使用緩存

2023-03-17 08:06 作者:程序員-王堅  | 我要投稿

項目簡介

這是一個基于.Net Core開發(fā)的緩存中間件,它支持各種緩存并提供了很多高級功能。它的主要目標是讓開發(fā)人員開發(fā)更簡單、特別是一些復(fù)雜的緩存場景。

項目特色功能

1、統(tǒng)一緩存接口:方便我們隨時調(diào)整緩存策略;

2、支持多種緩存:可以滿足我們多種業(yè)務(wù)場景;

3、支持多種緩存系列化:BinaryFormatter、Newtonsoft.Json,MessagePack和Protobuf;

4、支持緩存AOP:able, put,evict,可以簡化我們的代碼量;

5、多實例支持;

6、支持Diagnostics:方便我們跟蹤定位;

7、針對Redis支持特殊Provider:比如原子遞增遞減的操作等等;

8、二級緩存。

技術(shù)架構(gòu)

1、跨平臺:這是基于.Net Core開發(fā)的系統(tǒng),可以部署在Docker, Windows, Linux。

2、基于Net 6.0開發(fā)。

3、支持緩存類別:本地緩存:InMemory,SQLite;分布式緩存:StackExchange.Redis,csredis,EnyimMemcachedCore。

項目結(jié)構(gòu)

===

使用方法

**配置緩存
**

在Startup.cs,配置緩存

public void ConfigureServices(IServiceCollection services) { ? ?...... ? ?services.AddEasyCaching(option => ? ?{ ? ? ? ?//內(nèi)存緩存:default ? ? ? ?option.UseInMemory("default"); ? ? ? ?//內(nèi)存緩存:cus ? ? ? ?option.UseInMemory("cus"); ? ? ? ?//redis緩存:redis1 ? ? ? ?option.UseRedis(config => ? ? ? ?{ ? ? ? ? ? ?config.DBConfig.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6379)); ? ? ? ? ? ?config.DBConfig.SyncTimeout = 10000; ? ? ? ? ? ?config.DBConfig.AsyncTimeout = 10000; ? ? ? ? ? ?config.SerializerName = "mymsgpack"; ? ? ? ?}, "redis1") ? ? ? ?.WithMessagePack("mymsgpack")//with messagepack serialization ? ? ? ?; ? ? ? ?//redis緩存:redis2 ? ? ? ?option.UseRedis(config => ? ? ? ?{ ? ? ? ? ? ?config.DBConfig.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6380)); ? ? ? ?}, "redis2"); ? ? ? ?//sqlite緩存 ? ? ? ?option.UseSQLite(config => ? ? ? ?{ ? ? ? ? ? ?config.DBConfig = new SQLiteDBOptions { FileName = "my.db" }; ? ? ? ?}); ? ? ? ?//memcached 緩存 ? ? ? ?option.UseMemcached(config => ? ? ? ?{ ? ? ? ? ? ?config.DBConfig.AddServer("127.0.0.1", 11211); ? ? ? ?}); ? ? ? ?option.UseMemcached(Configuration); ? ? ? ?//fasterKv緩存 ? ? ? ?option.UseFasterKv(config => ? ? ? ?{ ? ? ? ? ? ?config.SerializerName = "msg"; ? ? ? ?}) ? ? ? ? ? ?.WithMessagePack("msg"); ? ?}); }

**使用方式
**

public class CusController : Controller{ ? ?//緩存 ? ?private readonly IEasyCachingProviderFactory _factory; ? ?public CusController(IEasyCachingProviderFactory factory) ? ?{ ? ? ? ?this._factory = factory; ? ?} ? ?// GET api/cus/inmem?name=Default ? ?[HttpGet] ? ?[Route("inmem")] ? ?public string Get(string name = EasyCachingConstValue.DefaultInMemoryName) ? ?{ ? ? ? ?//根據(jù)name,獲取緩存實例 ? ? ? ?var provider = _factory.GetCachingProvider(name); ? ? ? ?var val = name.Equals("cus") ? "cus" : "default"; ? ? ? ?var res = provider.Get("demo", () => val, TimeSpan.FromMinutes(1)); ? ? ? ?return $"cached value : {res}"; ? ?} ? ?...... }

ResponseCache緩存

[ResponseCache(Duration = 30, VaryByQueryKeys = new string[] { "page" })]public IActionResult List(int page = 0){return Content(page.ToString()); }

AOP緩存

[EasyCachingAble(Expiration = 10)]string GetCurrentUtcTime(); [EasyCachingPut(CacheKeyPrefix = "Castle")]string PutSomething(string str); [EasyCachingEvict(IsBefore = true)]void DeleteSomething(int id);


一個.Net Core開源緩存中間件,讓你更加簡單、方便使用緩存的評論 (共 條)

分享到微博請遵守國家法律
色达县| 鄂州市| 泾阳县| 廊坊市| 孝义市| 玉龙| 姜堰市| 平和县| 江都市| 乐清市| 台安县| 米泉市| 西盟| 尉犁县| 黄骅市| 仙游县| 运城市| 山阳县| 桑植县| 吕梁市| 阆中市| 凌源市| 霍山县| 台湾省| 慈利县| 凭祥市| 西盟| 保亭| 普兰县| 江阴市| 札达县| 蒲城县| 怀柔区| 朔州市| 湖北省| 丘北县| 大同市| 济宁市| 海晏县| 都匀市| 榆中县|