@@ -672,7 +672,7 @@ namespace Masuit.MyBlogs.Core.Controllers
{
item.ModifyDate = item.ModifyDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
item.PostDate = item.PostDate.ToTimeZone(HttpContext.Session.Get<string>(SessionKey.TimeZone));
- item.Online = cacheManager.GetOrAdd(nameof(PostOnline) + ":" + item.Id, new HashSet<string>()).Count;
+ item.Online = cacheManager.Get(nameof(PostOnline) + ":" + item.Id)?.Count ?? 0;
}
return Ok(list);
@@ -1,11 +1,11 @@
-using System;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Threading.Tasks;
-using Masuit.MyBlogs.Core.Infrastructure.Repository.Interface;
+using Masuit.MyBlogs.Core.Infrastructure.Repository.Interface;
using Masuit.MyBlogs.Core.Models.Entity;
using Masuit.Tools.Models;
using Microsoft.EntityFrameworkCore;
+using System;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Threading.Tasks;
namespace Masuit.MyBlogs.Core.Infrastructure.Repository
@@ -65,7 +65,7 @@
<PackageReference Include="TimeZoneConverter" Version="3.4.0" />
<PackageReference Include="WilderMinds.RssSyndication" Version="1.7.0" />
<PackageReference Include="WinInsider.System.Net.Http.Formatting" Version="1.0.14" />
- <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="5.1.28" />
+ <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="5.1.29" />
</ItemGroup>
<ItemGroup>
<Content Update="appsettings.json">
@@ -1,6 +1,5 @@
@using CacheManager.Core
@using System.Threading
-@using Masuit.MyBlogs.Core.Common
@implements IAsyncDisposable
@inject ICacheManager<HashSet<string>> CacheManager
@@ -27,7 +26,7 @@
CacheManager.Expire(key, ExpirationMode.Sliding, TimeSpan.FromMinutes(5));
_timer = new Timer(_ =>
- online = CacheManager.Get(key).Count;
+ online = CacheManager.Get(key)?.Count ?? 0;
InvokeAsync(StateHasChanged);
}, null, 0, 1000);
@@ -6,7 +6,7 @@
@{
string[] colors = { "success", "info", "primary", "warning", "danger", "default", "primary" };
- var online = CacheManager.GetOrAdd(nameof(PostOnline) + ":" + Model.Id, new HashSet<string>()).Count;
+ var online = CacheManager.Get(nameof(PostOnline) + ":" + Model.Id)?.Count ?? 0;
<div class="ibox wow fadeIn">
@@ -7,7 +7,7 @@
@model Masuit.MyBlogs.Core.Models.DTO.PostDto