예제 #1
0
        /// <summary>
        /// Selects records by the specified key-value pairs.
        /// </summary>
        /// <param name="searchProperties">Search properties.</param>
        /// <returns>Enumerable collection of records.</returns>
        public IEnumerable <FileCabinetRecord> Select(SearchProperties searchProperties)
        {
            if (searchProperties is null)
            {
                throw new ArgumentNullException(nameof(searchProperties));
            }

            var key = GenerateKey(searchProperties);

            if (!this.RequestCache.TryGetValue(key, out IEnumerable <FileCabinetRecord> records))
            {
                records = service.SelectByCriteria(searchProperties);
                this.RequestCache.Add(key, records);
            }

            return(records);
        }