예제 #1
0
        public ICacheable CacheItem <T>(ICacheable item)
        {
            if (_cache.Count >= MaxItemsPerCacheList)
            {
                RemoveOldest(typeof(T).Name);
            }

            if (!_cache.ContainsKey(typeof(T).Name))
            {
                _cache.Add(typeof(T).Name, new List <ICacheable> {
                    item
                });
                _cacheMetaData.Add(typeof(T).Name, new List <string>()
                {
                    (string)item.GetUniqueIdentifier <string>()
                });
                return(item);
            }

            _cache[typeof(T).Name].Add(item);
            _cacheMetaData[typeof(T).Name].Add((string)item.GetUniqueIdentifier <string>());
            return(item);
        }