SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a versioned list that I need to cache list items for.

The effect of which being:

  • If a user has permission to view non published items the cache can return the item pending approval.
  • However if the user does not have permission I can display the last published version of the list item.

Has anyone done this or know how/if it can be done, thanks?

I'm using C# and SharePoint 2010.

share|improve this question
Does this need any special threatment? Aslong as you do not elevate your code, the correct "version" will be cached (because of the users permissions)? – Frederik P. May 2 '12 at 8:26
THe correct version cached when ran by one user may not be the correct version when cached by another - so your cache has to be per user. – Ryan May 2 '12 at 17:46

Remember you should not cache the SPListItem itself as it contains a link to the SPWeb used to get it and will often require this to be alive. So get the information out of the SPListItem and into some repository objects.

Regarding security:

Disclaimer: I've never tried to use this, but it should work.

The SPListItem has a property SPReusableAcl inherited from ISecurableObject which you should be able to cache with you listitem information.

SPSite has a method DoesUserHavePermissions(SPReusableAcl acl, SPBasePermissions permissionMask) which should let you check the permissions of the current user against a cached ReusableAcl

share|improve this answer
Thanks, I'll try this out. – Daniel Little May 3 '12 at 0:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.