/// <summary>
        ///
        /// </summary>
        /// <param name="personalId"></param>
        /// <param name="data"></param>
        /// <param name="keys"></param>
        /// <returns></returns>
        public LoadingStatus TryFindKey(string personalId, out T data, params object[] keys)
        {
            LoadingStatus  loadStatus;
            BaseCollection collection;

            data       = default(T);
            personalId = AbstractEntity.EncodeKeyCode(personalId);
            if (TryGetGroup(personalId, out collection, out loadStatus))
            {
                string key = keys.Length > 0 ? AbstractEntity.CreateKeyCode(keys) : personalId;
                if (!collection.TryGetValue(key, out data))
                {
                    //修正旧版本无personalId参数调用
                    var tempKeys = new List <object>();
                    tempKeys.Add(personalId);
                    if (keys.Length > 0)
                    {
                        tempKeys.AddRange(keys);
                    }
                    key = string.IsNullOrEmpty(key) ? personalId : AbstractEntity.CreateKeyCode(tempKeys.ToArray());
                    collection.TryGetValue(key, out data);
                }
            }
            return(loadStatus);
        }
Beispiel #2
0
        /// <summary>
        /// 通过Key查找
        /// </summary>
        /// <param name="keys"></param>
        /// <returns></returns>
        public T FindKey(params object[] keys)
        {
            T      data;
            string key = AbstractEntity.CreateKeyCode(keys);

            if (TryGetEntity(key, out data))
            {
                return(data);
            }
            return(default(T));
        }
Beispiel #3
0
        /// <summary>
        /// Get entity of personal object
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="personalId"></param>
        /// <param name="keys"></param>
        /// <returns></returns>
        public static dynamic GetPersonalEntity(string entityType, string personalId, params object[] keys)
        {
            string key = AbstractEntity.EncodeKeyCode(personalId);

            if (keys.Length > 0)
            {
                key += "|" + AbstractEntity.CreateKeyCode(keys);
            }
            string       redisKey = string.Format("{0}_{1}", RedisConnectionPool.EncodeTypeName(entityType), key);
            CacheItemSet itemSet;

            return(GetPersonalEntity(redisKey, out itemSet));
        }
Beispiel #4
0
        /// <summary>
        /// Get entity of personal object
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="personalId"></param>
        /// <param name="keys"></param>
        /// <returns></returns>
        public static dynamic GetPersonalEntity(string entityType, string personalId, params object[] keys)
        {
            string key = personalId;

            if (keys.Length > 0)
            {
                key += "|" + AbstractEntity.CreateKeyCode(keys);
            }
            string       redisKey = string.Format("{0}_{1}", entityType, key);
            CacheItemSet itemSet;

            return(GetPersonalEntity(redisKey, out itemSet));
        }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="personalId"></param>
        /// <param name="data"></param>
        /// <param name="keys"></param>
        /// <returns></returns>
        public LoadingStatus TryFindKey(string personalId, out T data, params object[] keys)
        {
            LoadingStatus  loadStatus;
            BaseCollection collection;

            data = default(T);
            if (TryGetGroup(personalId, out collection, out loadStatus))
            {
                string key = AbstractEntity.CreateKeyCode(keys);
                if (!collection.TryGetValue(key, out data))
                {
                    //修正旧版本无personalId参数调用
                    key = string.IsNullOrEmpty(key) ? personalId : AbstractEntity.CreateKeyCode(personalId, key);
                    collection.TryGetValue(key, out data);
                }
            }
            return(loadStatus);
        }
Beispiel #6
0
        /// <summary>
        /// 取子类的Key,不需要personalId,不加载数据
        /// </summary>
        /// <param name="keys"></param>
        /// <returns></returns>
        public T TakeSubKey(params object[] keys)
        {
            string key = AbstractEntity.CreateKeyCode(keys);

            return(DataContainer.TakeEntityFromKey(key));
        }