Bizarre Sharepoint List cache issue

Sharepoint seems to be missing one of those useful settings like Domino has where you can specify when you want to use a cached version of a list/view, or get a new one. When I query a Sharepoint list, access a single item, make a change, and then query the same list, I get cached data regardless of the access method. Yet, if I loop through all the list entries, I will eventually find what I need. Not exactly the smartest way to do things.


Edit: I found a hack for this issue here

So let’s say I have a list of items to be worked on, and each is assigned to me. As I “check-out” each item, the status is changed to “In Queue”. When I am done with all of the items, I go to another list and close a parent item. So as I change the status, I need to check on the number of items that have a status of “Complete”, as opposed to “In Process” which is incomplete work. So we get a list, and we query:


Dim theList As SPList = theWeb.Lists.Item("ThingsToDo")
Dim theQuery As New SPQuery
Dim theColl As SPListItemCollection
<.... build our CAML query ...>
theQuery.Query = sb.ToString
theColl = theList.GetItems(theQuery)
<.. grab an item and change its status to "Complete" ..>
<.. now create a new query to determine if all are "Complete" ..>
theColl = Nothing
theColl = theList.GetItems(theQuery)

That last GetItems will simply return the same collection. I have not attempted to measure the time lag yet, but it seems to be over 5 minutes!!. In the end, I had to grab all items, and access their field values directly.


For Each listItem In theColl
    If listItem.Item("Status") = "In Process" Then
        blnNotDone = True
    End If 
Next

I think someone messed up this class. A forced refresh method would seem to be the ticket.


2 Responses to “Bizarre Sharepoint List cache issue”

  1. Mike Says:

    Do you create new SPQuert by theQuery = new SPQuery() or simply change Query string ?

  2. Administrator Says:

    Yes we did Mike. Same results.