/// <summary> /// Получает кэш запросов по имени или создает новый. /// </summary> /// <param name="name">Название</param> /// <param name="queryTemplate">Шаблон запросов.</param> /// <param name="options">Опции кэширования.</param> /// <returns>Возвращает экземпяр <see cref="CacheQuery"/>.</returns> public CacheQuery GetCacheQuery(string name, string queryTemplate, CacheOptions options) { CacheQuery result = null; lock (_caches) { if (!_caches.TryGetValue(name, out result)) { result = new CacheQuery(this, queryTemplate, options); _caches.Add(name, result); } } return(result); }
public CacheQuery(MySqlAdapter adapter, string queryTemplate, CacheOptions options) { this.queryTemplate = queryTemplate; this.adapter = adapter; cache = new MemoryCache(new MemoryCacheOptions() { SizeLimit = options.CacheSize }); entryOptions = new MemoryCacheEntryOptions() { AbsoluteExpirationRelativeToNow = options.AbsoluteExpirationRelativeToNow, SlidingExpiration = options.SlidingExpiration, Size = 1 }; }