Scut is a free, open source, stable game server framework, which support C#/Python/Lua script, and support Unity3d, Cocos2dx, FlashAir client access.
1.33k
stars
577
forks
source link
Modify entity then Delete or RemoveCache in 100ms,there will be some bug,cache queue will created new CacheItemSet #20
Open
Jesse1205 opened 8 years ago
Change code like this
public static dynamic GetPersonalEntity(string redisKey, out CacheItemSet itemSet) { itemSet = null; dynamic entity = null; KeyValuePair<string, CacheItemSet> itemPair; if (TryGetContainerCacheItem(redisKey, out itemPair)) { itemSet = itemPair.Value; if (itemSet != null) { switch (itemPair.Value.ItemType) { case CacheType.Entity: entity = itemPair.Value.ItemData; break; case CacheType.Dictionary: var set = itemPair.Value.ItemData as BaseCollection; if (set != null) { set.TryGetValue(itemPair.Key, out entity); } break; default: TraceLog.WriteError("Not suported CacheType:{0} for GetPersonalEntity key:{1}", itemPair.Value.ItemType, redisKey); break; } } } if (entity == null) { //while is remove entity is empty. //TraceLog.WriteComplement("GetPersonalEntity key:{0} is empty.", redisKey); } return entity; }
`public static bool TryGetContainerCacheItem(string redisKey, out KeyValuePair<string, CacheItemSet> itemPair, int periodTime = 0) { itemPair = default(KeyValuePair<string, CacheItemSet>); CacheItemSet cacheItem; string[] keys = (redisKey ?? "").Split('_'); if (keys.Length == 2 && !string.IsNullOrEmpty(keys[0])) { CacheContainer container = null; string typeName = RedisConnectionPool.DecodeTypeName(keys[0]); var schema = EntitySchemaSet.Get(typeName); periodTime = periodTime > 0 ? periodTime : schema.PeriodTime; if (_writePools != null && !_writePools.TryGetValue(typeName, out container)) { _writePools.InitContainer(typeName); _writePools.TryGetValue(typeName, out container); } if (container == null) return false;