Exemplo n.º 1
0
        public async Task <string> GetStringAsync(string i_Key)
        {
            string getActionResult;

            try
            {
                m_Logger.LogInformation(string.Format(FUNCTION_CONTEXT_FORMAT, "GetStringAsync", i_Key));
                var cacheObject = await m_Client.GetAsync <string>(i_Key);

                getActionResult = cacheObject.Value;
            }
            catch (Exception ex)
            {
                m_Logger.LogInformation(string.Format(EXCEPTION_MESSAGE, EngineType, "GetStringAsync", LogUtils.GetExceptionDetails(ex)));
                getActionResult = string.Empty;
            }

            return(getActionResult);
        }
Exemplo n.º 2
0
        public async Task <T> GetAsync <T>(string key)
        {
            var cacheItem = await _cache.GetAsync <T>(key);

            if (cacheItem == null)
            {
                _logger.Debug("Cache miss with key {0}", key);
                return(default(T));
            }

            _logger.Debug("Cache hit with key {0}", key);

            return(cacheItem);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Retrieves cached value from the cache using its key.
        /// If value is missing in the cache or expired it returns null.
        /// </summary>
        /// <typeparam name="T">the class type</typeparam>
        /// <param name="correlationId">(optional) transaction id to trace execution through call chain.</param>
        /// <param name="key">a unique value key.</param>
        /// <returns>cached value.</returns>
        public override async Task <T> RetrieveAsync <T>(string correlationId, string key)
        {
            CheckOpened(correlationId);

            return(await _client.GetAsync <T>(key));
        }