ABP缓存示例
private readonly ICacheManager _cacheManager; public ProgrammeManage(ICacheManager cacheManager)
{
_cacheManager = cacheManager;
} /// <summary>
/// 定时任务:更新缓存(仅查询今年的投票结果、按照节目顺序排序)
/// </summary>
/// <returns></returns>
public async Task SaveVoteResult()
{
GetAllProgrammeInfosByYearOutput result = GetVoteResult(DateTime.Now.Year).Result;
await _cacheManager.GetCache("GetAllProgrammeInfosByYearOutput")
.SetAsync("GetAllProgrammeInfosByYearOutput", result);
} /// <summary>
/// 查询缓存
/// </summary>
/// <param name="inputYear"></param>
/// <param name="sortProperty"></param>
/// <returns></returns>
public async Task<GetAllProgrammeInfosByYearOutput> GetVoteResult(long inputYear,string sortProperty)
{
var cache = _cacheManager
.GetCache("GetAllProgrammeInfosByYearOutput");
long year = inputYear == 0 ? DateTime.Now.Year : inputYear;
//先尝试读取缓存,缓存没有则读取数据库
var result =await cache.GetAsync("GetAllProgrammeInfosByYearOutput", async ()=> { return await GetVoteResult(year); }) as GetAllProgrammeInfosByYearOutput;
return result;
}
ABP缓存示例的更多相关文章
- 基于DDD的.NET开发框架 - ABP缓存Caching实现
返回ABP系列 ABP是“ASP.NET Boilerplate Project (ASP.NET样板项目)”的简称. ASP.NET Boilerplate是一个用最佳实践和流行技术开发现代WEB应 ...
- Asp.Net 自定义设置Http缓存示例(一)
一.自定义图片输出,启用客户端的图片缓存处理 代码示例: string path = Request.Url.LocalPath; if (path != null) { path = path.To ...
- ABP缓存
简介 缓存是做什么的? 简单的可以认为是一个键值对的数据存于内存中,高速读取.作用为了减少和数据库的交互 Abp中缓存的使用 public class InvoiceAppService : Appl ...
- ABP Zero示例项目登录报错“Empty or invalid anti forgery header token.”问题解决
ABP Zero项目,登录时出现如图"Empty or invalid anti forgery header token."错误提示的解决方法: 在 WebModule.cs的P ...
- ABP Zero示例项目问题总结
1.ABP Zero项目,登录时出现如图“Empty or invalid anti forgery header token.”错误提示 ABP Zero项目,登录时出现如图“Empty or in ...
- Abp zero 示例运行
https://aspnetboilerplate.com/Pages/Documents/Zero/Startup-Template-Core Introduction The easiest wa ...
- php静态文件缓存示例
//开始缓冲区 ob_start(); $cache_file = "./cache/4.3-static.html"; $cache_time = 1; //设置缓存更新时间 i ...
- ABP框架 - 缓存
文档目录 本节内容: 简介 ICacheManager ICache ITypedCache 配置 实体缓存 EntityCache 是如何工作 Redis 缓存集成 简介 ABP提供了一个缓存接口, ...
- ABP官方文档翻译 2.3 缓存
缓存 介绍 ICacheManager 警告:GetCache方法 ICache ITypedCache 配置 实体缓存 实体缓存如何工作 Redis缓存集成 介绍 ABP为缓存提供了一个抽象接口,它 ...
随机推荐
- Sphinx+MySQL5.1x+SphinxSE+mmseg中文分词
什么是Sphinx Sphinx 是一个全文检索引擎,一般而言,Sphinx是一个独立的搜索引擎,意图为其它应用提供快速.低空间占用.高结果相关度的全文搜索功能.Sphinx能够很easy的与SQL数 ...
- itunes app 下载链接的几种表现形式
第一种:itunes://itunes.apple.com/cn/app/id794862904 ,这是最普通的一种. 直接在浏览器中输入.就能够打开电脑上安装的itunes,并跳转到相应的app下载 ...
- NET WinForm 开发所见即所得的 IDE 开发环境
Github 开源:使用 .NET WinForm 开发所见即所得的 IDE 开发环境(Sheng.Winform.IDE)[2.源代码简要说明] GitHub:https://github.co ...
- Distribution download cancelled. Using distribution from 'https://services.gradle.org/distributions/
Distribution download cancelled. Using distribution from ‘https://services.gradle.org/distributions/ ...
- python property属性
能够检查參数,一直没注意这个语言特性,忽略了非常多细节,感谢 vitrox class Person( object ): def __init__( self, name ): if not isi ...
- mysqldump --single-transaction 和--lock-tables参数详解
mysqldump的备份原理 mysqldump在备份过程中,是采用查询备份相关表的数据,然后导出,拼接成insert语句的形式进行备份. 关于--single-transaction 和--lo ...
- iOS 日志自动上报
您好,欢迎使用腾讯Bugly!腾讯Bugly是腾讯公司为移动开发者开放的服务之一. 针对移动应用,腾讯Bugly提供了专业的Crash(崩溃).Android ANR(application n ...
- Newtonsoft.Json 序列化反序列化
public class People { public string name { get; set; } public string age { get; set; } public string ...
- 【u216】A+B Problem(aplusb)
Time Limit: 1 second Memory Limit: 128 MB [问题描述] 对于给定的A和B,求A+B的值. [输入格式] 输入文件aplusb.in的第1行为一个整数A,第2行 ...
- html 横线的代码
第一种: <hr style=" height:2px;border:none;border-top:2px dotted #185598;" /> 园点虚线 he ...