首页缓存计算时长调整
This commit is contained in:
parent
f94bdcc506
commit
83df6abc46
|
|
@ -0,0 +1,23 @@
|
|||
namespace LY.App.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// 日期时间帮助类
|
||||
/// </summary>
|
||||
public static class DateTimeHelper
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// //当前剩余秒数
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static int GetRemainSeconds()
|
||||
{
|
||||
// 当前时间
|
||||
DateTime now = DateTime.Now;
|
||||
// 当天结束时间(23:59:59.999)
|
||||
DateTime endOfDay = now.Date.AddDays(1).AddTicks(-1);
|
||||
int remainSeconds = (int)(endOfDay - DateTime.Now).TotalSeconds;
|
||||
return remainSeconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using LY.App.Common.Redis;
|
||||
using LY.App.Common;
|
||||
using LY.App.Common.Redis;
|
||||
using LY.App.Device;
|
||||
using LY.App.Model;
|
||||
using LY.App.Service;
|
||||
|
|
@ -48,7 +49,7 @@ namespace LY.App.Controllers
|
|||
var positions = await _positionService.Index();
|
||||
var alarmCount = await _redisService.GetOrSetAsync(RedisKeyList.index_data(),
|
||||
async () => await _alarmService.IndexCount(),
|
||||
TimeSpan.FromDays(1));
|
||||
TimeSpan.FromSeconds(DateTimeHelper.GetRemainSeconds()));
|
||||
var weather = await _redisService.GetOrSetAsync(RedisKeyList.Index_Weather,
|
||||
async () => await _weatherService.GetWeather(),
|
||||
TimeSpan.FromHours(3));
|
||||
|
|
|
|||
Loading…
Reference in New Issue