protected override void doRefresh() { try { if (_rwLock.TryEnterWriteLock(_writeWaiteTime)) { try { beforeDoRefresh(); _lst.Clear(); var cache = new ShareCacheStruct <T>(); cache.Foreach(addData); MathUtils.QuickSort <T>(_lst, comp); afterDoRefresh(); } catch (Exception e) { ConsoleLog.showErrorInfo(0, "DoRefresh Error:" + e.Message); } finally { if (_rwLock.IsWriteLockHeld) { _rwLock.ExitWriteLock(); } } } } catch (Exception e) { TraceLog.WriteError("DoRefresh Error:" + e.Message); } }
public void doIt() { ConsoleLog.showNotifyInfo("RankingClear Begin:"); RankingFactorNew.Singleton().Refresh <UserRanking>(typeof(RankingScore).ToString()); RankingFactorNew.Singleton().Loop <UserRanking>(typeof(RankingScore).ToString(), addRankingReward); // get fake data. // getFake(); // memoryData,clear lst and unload sharecache RankingFactorNew.Singleton().Clear <UserRanking>(typeof(RankingScore).ToString()); // redis delete List <int> keysremove = new List <int>(); var urcache = new ShareCacheStruct <UserRanking>(); float percent = GameConfigMgr.Instance().getInt("rankclear_perscent", 1) / 100.0f; int reduceScore = GameConfigMgr.Instance().getInt("rank_score_redice", 10000); float reduceAfterScorre = GameConfigMgr.Instance().getfloat("rank_clear_after", 0.1f); urcache.Foreach((string str, UserRanking ur) => { if (ur.Score > reduceScore) { ur.ModifyLocked(() => { ur.Score = (int)(reduceAfterScorre * ur.Score); }); } return(true); }); // ZyGames.Framework.Redis.RedisConnectionPool.Process(client => // { // string delKey = "$" + typeof(UserRanking).ToString(); // for(int i=0; i<keysremove.Count; ++i) // { // byte[] byteKeys = Encoding.UTF8.GetBytes(keysremove[i].ToString()); // client.HDel(delKey, byteKeys); // } // }); // mysql delete // var dbProvider = DbConnectionProvider.CreateDbProvider("ConnData"); // var command = dbProvider.CreateCommandStruct("UserRanking", CommandMode.Delete); // command.Parser(); // dbProvider.ExecuteQuery(System.Data.CommandType.Text, command.Sql, command.Parameters); // update UserRankingTotal RankingFactorNew.Singleton().Refresh <UserRankingTotal>(typeof(RankingTotal).ToString()); // add fake data mybe this is has not data .... // setFake(); RankingFactorNew.Singleton().Refresh <UserRanking>(typeof(RankingScore).ToString()); ConsoleLog.showNotifyInfo("RankingClear End"); }
public void doIt() { ConsoleLog.showNotifyInfo("RankingClear Begin:"); RankingFactorNew.Singleton().Refresh<UserRanking>(typeof(RankingScore).ToString()); RankingFactorNew.Singleton().Loop<UserRanking>(typeof(RankingScore).ToString(), addRankingReward); // get fake data. // getFake(); // memoryData,clear lst and unload sharecache RankingFactorNew.Singleton().Clear<UserRanking>(typeof(RankingScore).ToString()); // redis delete List<int> keysremove = new List<int>(); var urcache = new ShareCacheStruct<UserRanking>(); float percent = GameConfigMgr.Instance().getInt("rankclear_perscent", 1) / 100.0f; int reduceScore = GameConfigMgr.Instance().getInt("rank_score_redice", 10000); float reduceAfterScorre = GameConfigMgr.Instance().getfloat("rank_clear_after", 0.1f); urcache.Foreach((string str, UserRanking ur) => { if(ur.Score > reduceScore) { ur.ModifyLocked(() => { ur.Score = (int) (reduceAfterScorre*ur.Score); }); } return true; }); // ZyGames.Framework.Redis.RedisConnectionPool.Process(client => // { // string delKey = "$" + typeof(UserRanking).ToString(); // for(int i=0; i<keysremove.Count; ++i) // { // byte[] byteKeys = Encoding.UTF8.GetBytes(keysremove[i].ToString()); // client.HDel(delKey, byteKeys); // } // }); // mysql delete // var dbProvider = DbConnectionProvider.CreateDbProvider("ConnData"); // var command = dbProvider.CreateCommandStruct("UserRanking", CommandMode.Delete); // command.Parser(); // dbProvider.ExecuteQuery(System.Data.CommandType.Text, command.Sql, command.Parameters); // update UserRankingTotal RankingFactorNew.Singleton().Refresh<UserRankingTotal>(typeof(RankingTotal).ToString()); // add fake data mybe this is has not data .... // setFake(); RankingFactorNew.Singleton().Refresh<UserRanking>(typeof(RankingScore).ToString()); ConsoleLog.showNotifyInfo("RankingClear End"); }
/// <summary> /// Init word /// </summary> public static void Init() { _filter = new BadWordsFilter(); var cacheSet = new ShareCacheStruct <SensitiveWord>(); cacheSet.Foreach((k, v) => { _filter.AddKey(v.Word); return(true); }); }
/* * Method: heart * Desc: 检测服务器在线情况 * Author: guccang * Date: 2015-7-21 */ /// <summary> /// heart Document /// desc: 检测服务器在线情况 /// </summary> public void heart(object o) { var cache = new ShareCacheStruct <ServerInfoMode>(); cache.Foreach((string s1, ServerInfoMode sim) => { if (sim.offLineCnt < offLineCnt) { sim.ModifyLocked(() => { sim.offLineCnt += 1; }); } return(true); }); }
/// <summary> /// 尝试获取下个引导,未找到引导完成 /// </summary> /// <param name="guideId"></param> /// <param name="guideData"></param> /// <returns></returns> protected bool TryGetNextId(int guideId, out V guideData) { int nextGuidId = 0; guideData = _guideSet.FindKey(guideId); if (guideData == null) { _guideSet.Foreach((key, g) => { if (nextGuidId == 0 || g.ID < nextGuidId) { nextGuidId = g.ID; } return(true); }); } else { nextGuidId = guideData.NextID; } guideData = _guideSet.FindKey(nextGuidId); return(guideData != null); }
public void actionrealItemCnt(object state) { var cache = new ShareCacheStruct <ShareRealItemCnt>(); cache.Foreach(updateRealItemCnt); }
public void actionrealItemCnt(object state) { var cache = new ShareCacheStruct<ShareRealItemCnt>(); cache.Foreach(updateRealItemCnt); }
/// <summary> /// Init word /// </summary> public static void Init() { _filter = new BadWordsFilter(); var cacheSet = new ShareCacheStruct<SensitiveWord>(); cacheSet.Foreach((k, v) => { _filter.AddKey(v.Word); return true; }); }