当前位置: 首页 > news >正文

动易的网站系统广州近期流行的传染病

动易的网站系统,广州近期流行的传染病,国微 网站建设,静态网站做等级保护虽然 ASP.Net Core 中缺少 Cache 对象#xff0c;但它引入了三种不同的cache方式。内存缓存分布式缓存Response缓存Alachisoft 公司提供了一个开源项目 NCache#xff0c;它是一个高性能的#xff0c;分布式的#xff0c;可扩展的缓存框架#xff0c;NCache不仅比 Redis 快… 虽然 ASP.Net Core 中缺少 Cache 对象但它引入了三种不同的cache方式。内存缓存分布式缓存Response缓存Alachisoft 公司提供了一个开源项目 NCache它是一个高性能的分布式的可扩展的缓存框架NCache不仅比 Redis 快而且还提供了一些Redis所不具有的分布式特性如果你想了解 NCache 和 Redis 的异同可参考如下链接http://www.alachisoft.com/resources/comparisons/redis-vs-ncache.php  这篇文章我们将会讨论如何在 ASP.Net Core 中使用 NCache。要想在 ASP.Net Core 中使用 NCache需要通过 NuGet 安装如下包你可以通过 NuGet Package Manager console 窗口输入如下命令进行安装。 Install-Package Alachisoft.NCache.SessionServices使用 IDistributedCache 要想在 ASP.Net Core 中使用分布式缓存需要实现 IDistributedCache 接口这个接口主要用于让第三方的缓存框架无缝对接到 ASP.Net Core 中下面是 IDistributedCache 的骨架代码。namespace Microsoft.Extensions.Caching.Distributed{public interface IDistributedCache{byte[] Get(string key);void Refresh(string key);void Remove(string key);void Set(string key, byte[] value,DistributedCacheEntryOptions options);}}配置 NCache 要想把 NCache 作为分布式缓存需要在 ConfigureServices() 中调用 AddNCacheDistributedCache 扩展方法将其注入到容器中如下代码所示// This method gets called by the runtime. Use this method to add services to the container.public void ConfigureServices(IServiceCollection services){services.AddNCacheDistributedCache(configuration {configuration.CacheName  IDGDistributedCache;configuration.EnableLogs  true;configuration.ExceptionsEnabled  true;});services.AddControllersWithViews();}使用 NCache 进行CURD 为了方便演示先来定义一个 Author 类如下代码所示public class Author{public int AuthorId { get; set; }public string FirstName { get; set; }public string LastName { get; set; }}接下来实现从 NCache 中读取 Author 对象如果缓存中存在 Author 对象则直接从缓存中读取如果缓存中没有则需要先从数据库中获取 Author然后再将 Author 塞入到 Cache 中下面的具体代码逻辑仅供参考。public async TaskAuthor GetAuthor(int id){_cache  NCache.InitializeCache(CacheName);var cacheKey  Key;Author author  null;if (_cache ! null){author  _cache.Get(cacheKey) as Author;}if (author  null) //Data not available in the cache{if (_cache ! null){_cache.Insert(cacheKey, author, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(10), Alachisoft.NCache.Runtime.CacheItemPriority.Default);}}return author;}NCache 由 Alachisoft 出品给 .NET 世界提供了一种分布式缓存的解决方案同时你也能看到 IDistributedCache 是一套标准的用于分布式缓存的高层API方便第三方的缓存无缝接入比如RedisMongodbMysql 等等。译文链接https://www.infoworld.com/article/3342120/how-to-use-ncache-in-aspnet-core.html
http://www.pierceye.com/news/189343/

相关文章:

  • 视频直播网站开发运营步骤十大免费erp软件
  • 域名备案和网站备案有什么不同wap 网站
  • 没备案的网站百度收录博客营销
  • 网站开发新技术wordpress 搜索词调用
  • 凡科手机建站教程wordpress 搜索引擎
  • asp企业网站源码下载免费ppt模板公众号
  • 西斗门的网站建设短网址生成器有哪些
  • 一站式织梦网站模板工信部备案查询网官网
  • 网站导航做外链桂林seo
  • 青岛网站建设q479185700棒软件开发者是指
  • 福永公司网站建设空间网站链接怎么做
  • 百度的企业网站谷歌浏览器下载安卓版
  • 网站建设总体情况网站设计宁波
  • 西宁做网站_君博示范360建筑网会员
  • 做DJ网站违法吗汕头seo网站推广
  • 上海网站建设网站宁波网站模板哪家性价比高
  • 珠海专业做网站制作做网站网站的代理算网站罪吗
  • 建设局网站简介通信建设网站
  • php做网站用什么开发工具大专软件技术工资一般多少
  • 网站建设服务承诺wordpress 博客园
  • seo综合查询站长工具关键词全网营销案例
  • 深圳专业做网站设计政务服务网站建设性建议
  • 做暧免费观看网站哪个网站可以给图片做链接
  • wordpress最好的主题东莞债务优化
  • 全国网站建设大赛网店网站设计
  • 学网站建设需要学多久wordpress火车头插件
  • wordpress 网站实例中国纪检监察报app下载
  • 网站链接dw怎么做营销推广方法
  • 觅知网 大而全的高质量素材站开发手机网站用什么好
  • 建设一个广告联盟的网站医院网站设计与实现