示例#1
0
 private static string GetCacheId(Guid listId, SPListItemCollectionOptions options)
 {
     return(string.Join(":", new[]
     {
         "ListItems.List",
         listId.ToString("N"),
         options.PageSize.ToString(CultureInfo.InvariantCulture),
         options.PageIndex.ToString(CultureInfo.InvariantCulture),
         options.SortBy,
         options.SortOrder.ToString(),
         string.Join(":", options.ViewFields),
         options.ViewQuery
     }));
 }
示例#2
0
        public PagedList <SPListItem> List(Guid listId, SPListItemCollectionOptions options = null)
        {
            if (options == null)
            {
                options = new SPListItemCollectionOptions {
                    PageSize = DefaultPageSize
                };
            }

            var cacheId   = GetCacheId(listId, options);
            var listItems = (PagedList <SPListItem>)cacheService.Get(cacheId, CacheScope.Context | CacheScope.Process);

            if (listItems == null)
            {
                listItems = listItemService.List(listId, options);
                cacheService.Put(cacheId, listItems, CacheScope.Context | CacheScope.Process, new[] { Tag(listId) }, CacheTimeOut);
            }
            return(listItems);
        }