Esempio n. 1
0
        /// <summary>
        /// Retrives an object from cache using the specified key.
        /// </summary>
        /// <param name="key">Key which will be used to retrieve the same object.</param>
        /// <returns>Object retrieved from the cache based on the key specified.</returns>
        public object Get(string key)
        {
            Asserter.AssertIsNotNullOrEmptyString("key", key);
            object value = null;
            object returnValue;

            if (LocalCacheStorage.TryGetValue(key, out returnValue))
            {
                value = returnValue;
            }

            return(value);
        }
Esempio n. 2
0
        /// <summary>
        /// Updates an object in cache.
        /// </summary>
        /// <param name="key">The key of the item to update.</param>
        /// <param name="value">The value to update it to.</param>
        public void Update(TimeSpan timeout, string key, object value)
        {
            Asserter.AssertIsNotNullOrEmptyString("key", key);
            Asserter.AssertIsNotNull("value", value);
            object returnValue;

            if (LocalCacheStorage.TryGetValue(key, out returnValue))
            {
                LocalCacheStorage[key] = value;
            }
            else
            {
                throw new CacheKeyNotFoundException(key, CacheStoreName, GetType());
            }
        }