Example #1
0
    public async Task <IPagedList <Vacancy> > GetVacancies(int page = 1, int pageSize = 10)
    {
        var key = $"vacancy{page}_{pageSize}";

        var result = _cache.Get(key) as IPagedList <Vacancy>;

        if (result == null)
        {
            var items = await _repository.GetVacancies(page, pageSize);

            var totalItemsCount = await _repository.GetVacanciesCount();

            result = new StaticPagedList <Vacancy>(items, page, pageSize, totalItemsCount);
            _cache.Set(key, result, GetMemoryCacheEntryOptions());
        }

        return(result);
    }