public async Task Handle(OnlinePushEvent p_event) { StringCache sc = new StringCache(p_event.PrefixKey); if (p_event.Receivers != null && p_event.Receivers.Count > 0) { foreach (var id in p_event.Receivers) { if (Online.All.TryGetValue(id, out var ls) && ls != null && ls.Count > 0) { // 在线推送,直接放入推送队列 if (p_event.PushFirstSession) { ls[0].AddMsg(p_event.Msg); await sc.Set(null, true); } else { foreach (var ci in ls) { ci.AddMsg(p_event.Msg); } // 设置处理标志: msg:Push:6位id前缀:userid = true await sc.Set(id, true); } } } } // 统计总数+1 await sc.Increment("cnt"); }
public async Task <long> CacheLong(string p_key, long p_val) { var cache = new StringCache("Test:Long"); await cache.Set(p_key, p_val); return(await cache.Get <long>(p_key)); }
public async Task <string> CacheStr(string p_key, string p_val) { var cache = new StringCache("Test:Str"); await cache.Set(p_key, p_val); return(await cache.Get <string>(p_key)); }
public async Task Handle(IsOnlineEvent p_event) { var sc = new StringCache(p_event.CacheKey); var ls = Online.GetSessions(p_event.UserID); if (ls != null && ls.Count > 0) { await sc.Set(null, "true"); } // 统计总数+1 await sc.Increment("cnt"); }
public async Task CacheStrObj(string p_key, string p_name, int p_age) { var cache = new StringCache("Test:StrObj"); await cache.Set(p_key, new TestCacheObject { Name = p_name, Age = p_age }); var obj = await cache.Get <TestCacheObject>(p_key); if (obj != null && !string.IsNullOrEmpty(obj.Name)) { _log.Information(obj.Name); } }
public async Task Handle(UnregisterEvent p_event) { var sc = new StringCache(p_event.CacheKey); var ci = Online.GetSession(p_event.UserID, p_event.SessionID); if (ci != null) { await sc.Set(null, "true"); await ci.Close(); } // 统计总数 await sc.Increment("cnt"); }