本文整理汇总了C#中ShareCacheStruct.Foreach方法的典型用法代码示例。如果您正苦于以下问题:C# ShareCacheStruct.Foreach方法的具体用法?C# ShareCacheStruct.Foreach怎么用?C# ShareCacheStruct.Foreach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShareCacheStruct
的用法示例。
在下文中一共展示了ShareCacheStruct.Foreach方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: doIt
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");
}
示例2: actionrealItemCnt
public void actionrealItemCnt(object state)
{
var cache = new ShareCacheStruct<ShareRealItemCnt>();
cache.Foreach(updateRealItemCnt);
}
示例3: Init
/// <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;
});
}