public PagedList <Document> List(Guid libraryId, DocumentListOptions options = null) { if (options == null) { options = new DocumentListOptions { PageSize = DefaultPageSize }; } if (string.IsNullOrEmpty(options.Url)) { options.Url = GetUrl(libraryId); } var cacheId = GetCacheId(libraryId, options); var documents = (PagedList <Document>)cacheService.Get(cacheId, CacheScope.Context | CacheScope.Process); if (documents == null) { var listItems = listItemService.List(libraryId, options); documents = new PagedList <Document>(listItems.Select(_ => new Document(_))) { PageSize = options.PageSize, PageIndex = options.PageIndex, TotalCount = listItems.TotalCount }; cacheService.Put(cacheId, documents, CacheScope.Context | CacheScope.Process, new[] { Tag(libraryId) }, CacheTimeOut); } return(documents); }
private static string GetCacheId(Guid applicationId, DocumentListOptions options) { return(string.Join(":", new[] { "Documents.List", applicationId.ToString("N"), options.PageSize.ToString(CultureInfo.InvariantCulture), options.PageIndex.ToString(CultureInfo.InvariantCulture), options.SortBy, options.SortOrder.ToString(), options.FolderPath ?? string.Empty })); }