Ejemplo n.º 1
0
        /// <summary>
        ///     功能:设置永久缓存项(服务器上key存在就替换,不存在就添加)
        /// </summary>
        /// <param name="key">缓存键值</param>
        /// <param name="value">缓存值</param>
        /// <returns>是否设置成功</returns>
        public static async Task <bool> AddAsync(string key, object value)
        {
            bool blnSuccess = false;

            if (null != s_cacheStrategy)
            {
                string strKey = GlobalHelper.GetLowerString(key);

                try
                {
                    blnSuccess = await s_cacheStrategy.AddAsync(strKey, value, s_cacheExpiration);
                }
                catch (Exception ex)
                {
                    SysLogHelper.LogMessage("CacheHelper.AddAsync", ex.Message, LogLevel.Error, WriteLogType.FileLog);
                }
            }

            return(blnSuccess);
        }