/// <summary>
        /// 返回指定ID的对象
        /// </summary>
        /// <param name="objId"></param>
        /// <returns></returns>
        public override object GetObject(string objId)
        {
            if (objId == null || objId.Length == 0)
            {
                return(null);
            }

            lock (lockObject)
            {
                object returnObject = null;

                //处理本地缓存
                if (localCache != null)
                {
                    returnObject = localCache.GetObject(objId);
                    if (returnObject != null)
                    {
                        return(returnObject);
                    }
                }

                returnObject = dataCache.Get(GetInputKey(objId));

                //添加到本地缓存
                if (returnObject != null && localCache != null)
                {
                    localCache.AddObject(objId, returnObject, localTimeSpan);
                }

                return(returnObject);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// SharedCache에 특정 키의 값을 가져옵니다.
        /// </summary>
        /// <param name="sharedCache"></param>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static bool TryGet <T>(this IndexusProviderBase sharedCache, string key, out T value)
        {
            sharedCache.ShouldNotBeNull("sharedCache");
            key.ShouldNotBeWhiteSpace("key");

            if (IsDebugEnabled)
            {
                log.Debug("SharedCache 시스템에서 캐시 값을 로드합니다... key=[{0}]", key);
            }

            try {
                value = sharedCache.Get <T>(key);

                if (IsDebugEnabled)
                {
                    log.Debug("SharedCache 시스템에서 캐시 값을 로드했습니다. key=[{0}], value=[{1}]", key, value);
                }

                return(true);
            }
            catch {
                value = default(T);
            }
            return(false);
        }