From 5c13cba7e2a40abcc9da5490df71f6d225a7cfaa Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 30 Aug 2019 12:36:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=94=A8=E6=88=B7=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E9=9D=99=E6=80=81=E7=B1=BB=E5=A2=9E=E5=8A=A0=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Helper/UserHelper.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Bootstrap.Client.DataAccess.MongoDB/Helper/UserHelper.cs b/Bootstrap.Client.DataAccess.MongoDB/Helper/UserHelper.cs index 8d119b2c..76f4df24 100644 --- a/Bootstrap.Client.DataAccess.MongoDB/Helper/UserHelper.cs +++ b/Bootstrap.Client.DataAccess.MongoDB/Helper/UserHelper.cs @@ -1,4 +1,5 @@ -using MongoDB.Driver; +using Longbow.Cache; +using MongoDB.Driver; using System; using System.Collections.Generic; @@ -7,10 +8,15 @@ namespace Bootstrap.Client.DataAccess.MongoDB class UserHelper { /// - /// + /// 获取所有用户缓存数据键值 + /// + public const string RetrieveUsersDataKey = "UserHelper-RetrieveUsers"; + + /// + /// 查询所有用户 /// /// - public static IEnumerable Retrieves() + public static IEnumerable Retrieves() => CacheManager.GetOrAdd(RetrieveUsersDataKey, key => { var project = Builders.Projection.Include(u => u.Id) .Include(u => u.UserName) @@ -19,6 +25,6 @@ namespace Bootstrap.Client.DataAccess.MongoDB .Include(u => u.Roles) .Include(u => u.ApprovedTime); return DbManager.Users.Find(user => user.ApprovedTime != DateTime.MinValue).Project(project).ToList(); - } + }); } }