缓存更新
This commit is contained in:
parent
1d9da8d6e6
commit
6c31a6a72d
|
|
@ -50,7 +50,7 @@ namespace LY.App.Controllers
|
||||||
var positions = await _positionService.Index();
|
var positions = await _positionService.Index();
|
||||||
var alarmCount = await _redisService.GetOrSetAsync(RedisKeyList.index_data(),
|
var alarmCount = await _redisService.GetOrSetAsync(RedisKeyList.index_data(),
|
||||||
async () => await _alarmService.IndexCount(),
|
async () => await _alarmService.IndexCount(),
|
||||||
TimeSpan.FromDays(1));
|
TimeSpan.FromSeconds(GetLeftTime()));
|
||||||
var weather = await _redisService.GetOrSetAsync(RedisKeyList.Index_Weather,
|
var weather = await _redisService.GetOrSetAsync(RedisKeyList.Index_Weather,
|
||||||
async () => await _weatherService.GetWeather(),
|
async () => await _weatherService.GetWeather(),
|
||||||
TimeSpan.FromHours(3));
|
TimeSpan.FromHours(3));
|
||||||
|
|
@ -66,6 +66,17 @@ namespace LY.App.Controllers
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int GetLeftTime() {
|
||||||
|
DateTime now = DateTime.Now;
|
||||||
|
|
||||||
|
// 今天的结束时间 23:59:59
|
||||||
|
DateTime endOfDay = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59);
|
||||||
|
// 相差时间
|
||||||
|
TimeSpan remaining = endOfDay - now;
|
||||||
|
// 剩余秒数
|
||||||
|
return (int)remaining.TotalSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<List<SyncLocation>> GetUserLocation()
|
private async Task<List<SyncLocation>> GetUserLocation()
|
||||||
{
|
{
|
||||||
var keys = await _redisService.GetAllKeysAsync("user_locationbyid_*");
|
var keys = await _redisService.GetAllKeysAsync("user_locationbyid_*");
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
"log2db": true, //是否记录
|
"log2db": true, //是否记录
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"DefaultConnection": "server=114.66.57.139;port=23306;database=lyapp;user=root;password=dklymysql;Pooling=true;"
|
"DefaultConnection": "server=114.66.57.139;port=33306;database=lyapp;user=root;password=dklymysql;Pooling=true;"
|
||||||
},
|
},
|
||||||
"Token": {
|
"Token": {
|
||||||
"SecretKey": "HWLSNPM+OhlFe4wwEV/teSWsxGjrWbxKnHonxW5Z+mFlQq3zonv5",
|
"SecretKey": "HWLSNPM+OhlFe4wwEV/teSWsxGjrWbxKnHonxW5Z+mFlQq3zonv5",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue