public virtual object RetrieveFromCache(string commandText, int cacheAge)
        {
            this.CleanCache();
            Dictionary <string, BaseTableCache.CacheEntry> obj = this.cache;
            object result;

            lock (obj)
            {
                if (!this.cache.ContainsKey(commandText))
                {
                    result = null;
                }
                else
                {
                    BaseTableCache.CacheEntry cacheEntry = this.cache[commandText];
                    if (DateTime.Now.Subtract(cacheEntry.CacheTime).TotalSeconds > (double)cacheAge)
                    {
                        result = null;
                    }
                    else
                    {
                        result = cacheEntry.CacheElement;
                    }
                }
            }
            return(result);
        }
Example #2
0
 public virtual void AddToCache(string commandText, object resultSet)
 {
     this.CleanCache();
     BaseTableCache.CacheEntry value = default(BaseTableCache.CacheEntry);
     value.CacheTime    = DateTime.Now;
     value.CacheElement = resultSet;
     lock (this.cache)
     {
         if (!this.cache.ContainsKey(commandText))
         {
             this.cache.Add(commandText, value);
         }
     }
 }