public TreasureReel Get(int id) { if (id <= 0) { return(null); } TreasureReel treasure_reel = null; if (_treasure_reelMap.TryGetValue(id, out treasure_reel)) { _refMap[treasure_reel.Id] = GetCurrentTimeTick(); ReleaseData(false); return(treasure_reel); } treasure_reel = DbClassLoader.Instance.QueryData <TreasureReel>(ConfigDataBase.Instance.DbAccessorFactory, id); if (treasure_reel == null) { #if UNITY_EDITOR LoggerManager.Instance.Warn("Invalid `id` value in table `treasure_reel` : {0}", id); #endif return(null); } _treasure_reelMap.Add(id, treasure_reel); if (_refMap.ContainsKey(treasure_reel.Id) == false) { _refMap.Add(treasure_reel.Id, GetCurrentTimeTick()); } ReleaseData(false); return(treasure_reel); }
public void MemoryUpdate(int key, TreasureReel treasure_reel) { TreasureReels.RemoveAll(n => n.Id == key); if (_treasure_reelMap.ContainsKey(key)) { _treasure_reelMap.Remove(key); if (_refMap.ContainsKey(key)) { _refMap.Remove(key); } } if (treasure_reel != null) { TreasureReels.Add(treasure_reel); _treasure_reelMap.Add(key, treasure_reel); _refMap.Add(key, DateTime.Now.Ticks); } }