Esempio n. 1
0
        /// <summary>
        /// Retrieve cached item
        /// </summary>
        /// <typeparam name="T">Type of cached item</typeparam>
        /// <param name="key">Name of cached item</param>
        /// <param name="value">Cached value. Default(T) if item doesn't exist.</param>
        /// <returns>Cached item as type</returns>
        public static bool Get <T>(string key, int clientId, int countryId, int buId, out T value)
        {
            try
            {
                var result         = DotnetCoreSvr.GetObserve();
                var individualItem = result.FirstOrDefault(s => s.TableName == key && s.Changed == true);
                if (individualItem != null)
                {
                    Clear(key, individualItem);
                }

                if (!Exists(key))
                {
                    value = default(T);
                    return(false);
                }
                value = Redishelper.GetItem <T>(key);
            }
            catch (Exception ex)
            {
                value = default(T);
                return(false);
            }
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Retrieve cached item
        /// </summary>
        /// <typeparam name="T">Type of cached item</typeparam>
        /// <param name="key">Name of cached item</param>
        /// <param name="value">Cached value. Default(T) if item doesn't exist.</param>
        /// <returns>Cached item as type</returns>
        public static bool Get <T>(string key, int clientId, int countryId, int buId, out T value)
        {
            try
            {
                string consolidatedKey = clientId.ToString() + countryId.ToString() + buId.ToString() + key;
                if (EntityChangeObserverMaster.DataGetObserver(key, clientId, countryId, buId))
                {
                    Clear(consolidatedKey);
                }

                if (!Exists(consolidatedKey))
                {
                    value = default(T);
                    return(false);
                }

                value = Redishelper.GetItem <T>(consolidatedKey);
            }
            catch (Exception ex)
            {
                value = default(T);
                return(false);
            }

            return(true);
        }