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.

  • 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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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