提交代码
This commit is contained in:
parent
df6ca929df
commit
6aa9298974
|
|
@ -49,5 +49,14 @@ public class MonitorController : CloudGamingControllerBase
|
|||
return await new MonitorBLL(ServiceProvider).GetAppMonitorHourAsync(startTimeStamp, endTimeStamp);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前在线人数
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<List<object>> GetCurrentOnlineUsers()
|
||||
{
|
||||
return await new MonitorBLL(ServiceProvider).GetCurrentOnlineUsers();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
using CloudGaming.Code.Account;
|
||||
using CloudGaming.Code.AppExtend;
|
||||
using CloudGaming.Code.DataAccess;
|
||||
using CloudGaming.DtoModel.Account.User;
|
||||
using CloudGaming.DtoModel.Other;
|
||||
|
||||
using Microsoft.Win32;
|
||||
|
|
@ -193,5 +196,28 @@ public class MonitorBLL : CloudGamingBase
|
|||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前在线人数列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<object>> GetCurrentOnlineUsers()
|
||||
{
|
||||
//今日登录人数
|
||||
//RedisCache.StringGet<>
|
||||
//var todayLoggedInUsers = await cloudGamingBase.Dao.DaoExt.Context.T_User_LoginDay_Log.Where(it => it.CreateTimeDay == day).CountAsync();
|
||||
var currentOnlineUsers = await RedisServerCache.ScanKeysAsync($"{AccountExtend.UserInfoRedisKeyPrefix}:*");
|
||||
//currentOnlineUsers.
|
||||
List<object> userInfoCaches = new List<object>();
|
||||
foreach (var userKey in currentOnlineUsers)
|
||||
{
|
||||
var userInfoCache = await RedisCache.StringGetAsync<UserInfoCache>(userKey);
|
||||
if (userInfoCache != null)
|
||||
{
|
||||
userInfoCaches.Add(new { userInfoCache.UserId, userInfoCache.IsPay, userInfoCache.Diamond, userInfoCache.NickName, userInfoCache.PhoneNum });
|
||||
}
|
||||
}
|
||||
return userInfoCaches;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ end
|
|||
/// <param name="pattern"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <returns></returns>
|
||||
public static List<string> ScanKeys(this IServer server, string pattern, int pageSize = 100)
|
||||
public static List<string> ScanKeys(this IServer server, string pattern, int pageSize = 1000)
|
||||
{
|
||||
var matchingKeys = server.Keys(pattern: pattern, pageSize: pageSize).Select(it => it.ToString()).ToList();
|
||||
return matchingKeys;
|
||||
|
|
@ -261,7 +261,7 @@ end
|
|||
/// <param name="pageSize">每次扫描的页大小</param>
|
||||
/// <param name="database">数据库编号,默认值为 -1 表示全部数据库</param>
|
||||
/// <returns>匹配的键的字符串列表</returns>
|
||||
public static async Task<List<string>> ScanKeysAsync(this IServer server, string pattern, int pageSize = 100, int database = -1)
|
||||
public static async Task<List<string>> ScanKeysAsync(this IServer server, string pattern, int pageSize = 1000, int database = -1)
|
||||
{
|
||||
var matchingKeys = new List<string>();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user