Exemplo n.º 1
0
        private LruCache <string, DataEntry> GetCacheForPrefix(string prefix, bool createIfNonExisting)
        {
            LruCache <string, DataEntry> cache;

            if (this.cachesByPrefix.TryGetValue(prefix, out cache))
            {
                return(cache);
            }

            if (!createIfNonExisting)
            {
                return(null);
            }

            lock (this.cachesByPrefix)
            {
                if (!this.cachesByPrefix.TryGetValue(prefix, out cache))
                {
                    cache = new LruCache <string, DataEntry>(100);
                    this.cachesByPrefix[prefix] = cache;
                    cache.ChangeCapacity(this.MaxCapacityPerPrefix, false);
                }

                return(cache);
            }
        }