Пример #1
0
 private static string GetCacheId(Guid applicationId, SPListItemGetOptions options)
 {
     return(string.Join(":",
                        new[]
     {
         "ListItems.Get",
         applicationId.ToString("N"),
         GetListItemId(options)
     }));
 }
Пример #2
0
        public bool CanEdit(Guid listId, SPListItemGetOptions options)
        {
            var cacheId = CanEditCacheKey(listId, options);
            var canEdit = (bool?)cacheService.Get(cacheId, CacheScope.Context | CacheScope.Process);

            if (canEdit == null)
            {
                canEdit = listItemService.CanEdit(listId, options);
                cacheService.Put(cacheId, canEdit, CacheScope.Context | CacheScope.Process, new string[] { }, CacheTimeOut);
            }
            return((bool)canEdit);
        }
Пример #3
0
        public SPListItem Get(Guid listId, SPListItemGetOptions options)
        {
            var cacheId  = GetCacheId(listId, options);
            var listItem = (SPListItem)cacheService.Get(cacheId, CacheScope.Context | CacheScope.Process);

            if (listItem != null)
            {
                return(listItem);
            }

            listItem = listItemService.Get(listId, options);
            cacheService.Put(cacheId, listItem, CacheScope.Context | CacheScope.Process, new[] { Tag(listId) }, CacheTimeOut);
            return(listItem);
        }
Пример #4
0
 private static string CanEditCacheKey(Guid applicationId, SPListItemGetOptions options)
 {
     return(string.Concat("ListItems.CanEdit:", applicationId.ToString("N"), ":", GetListItemId(options)));
 }
Пример #5
0
 private static string GetListItemId(SPListItemGetOptions options)
 {
     return(options.ItemId.HasValue ? options.ItemId.Value.ToString(CultureInfo.InvariantCulture) : options.UniqueId.ToString("N"));
 }