/// <summary> /// 添加指定ID的对象 /// </summary> /// <param name="objId"></param> /// <param name="o"></param> public override void AddObject(string objId, object o) { if (objId == null || objId.Length == 0 || o == null) { return; } lock (lockObject) { if (Timeout <= 0) { dataCache.Add(GetInputKey(objId), o); } else { dataCache.Add(GetInputKey(objId), o, DateTime.Now.AddSeconds(Timeout)); } //处理本地缓存 if (localCache != null) { localCache.AddObject(objId, o, localTimeSpan); } } }
/// <summary> /// 캐시 저장소에 특정 키의 값을 저장합니다. /// </summary> public static bool TryAdd(this IndexusProviderBase sharedCache, string key, object payload, DateTime?expires = null, IndexusMessage.CacheItemPriority?priority = null) { sharedCache.ShouldNotBeNull("sharedCache"); key.ShouldNotBeWhiteSpace("key"); return (With.TryFunction(() => { if (IsDebugEnabled) { log.Debug("SharedCache 시스템에 캐시 정보를 저장합니다... key=[{0}], payload=[{1}]", key, payload); } sharedCache.Add(key, payload, expires.GetValueOrDefault(DateTime.Now.AddYears(1)), priority.GetValueOrDefault(IndexusMessage.CacheItemPriority.Normal)); if (IsDebugEnabled) { log.Debug( "SharedCache 시스템에 캐시 정보를 저장했습니다!!! key=[{0}], payload=[{1}], expires=[{2}], priority=[{3}]", key, payload, expires, priority); } return true; }, () => false)); }