Question

I have a really strange problem. I'm using object cache to faster retrieve results when using SPQuery.

My code to get items is as follows:

PortalSiteMapProvider ps = PortalSiteMapProvider.CurrentNavSiteMapProviderNoEncode;
var items = ps.GetCachedListItemsByQuery(((PortalSiteMapNode)ps.CurrentNode).WebNode, "mylistname", myQuery, site.RootWeb);

When I run this code I get all results which satisfies condition in query (no matter how many times I refresh page). However if I make any changes to list (add or delete item), the object cache returns the changed set of items only once. Next time I refresh page I get 0 results.

E.g. if I had 5 items and then I add 1 new item, I get 6 items which is correct result. But when I refresh page again I get 0 results. This state persists until I recycle app pool or flush object cache.

My Object cache is set to 300MB, it's checking for changes when query is executed and multiplier value is set to 3.

Any ideas what could be source of my problems?

Any advice is welcomed! Thanks.

EDIT:

I looked into ULS and found this entries when 0 items are returned:

Cache miss for query Web (nor all entries not found) "query .... "
Fetching 4294967295 items.
Fetching super user items.
Fetching SuperReader items.
Merging super user and super reader items.
Cache Hit for query Web "query ... "
Creating result set.
Adding super user IDs.
Adding Super Reader IDs.
Nothing from SuperReaders.
Was it helpful?

Solution

"Cache miss for query Web" may be the answer. You may be looking at the ULS log for the wrong portion. I would look at the ULS log for the first successful run and see if there is not a cache miss for the list that results in a cache dump for the list you are querying.

You may be able to remedy by changing the query from server side to client side. If I recall correctly client side queries tend to pull the whole list before running the query, so I think you may get cache hits every time.

OTHER TIPS

Cache misses are mostly likely to happen because of insufficient memory as they all are stored in Ram. If not then mostly cause must do with the Cache configuration. I would suggest to try the different settings specified for the object cache like changing the maxSize directly in the web.config etc. in the article below,

http://technet.microsoft.com/en-us/library/cc770229(v=office.14).aspx

Also ensure that the object cache user accounts are configured properly like mentioned in the below article,

http://technet.microsoft.com/en-us/library/ff758656(v=office.14).aspx

i think and not sure this is realted to the cache profile modify an item make the cache dirty and thats why your next request is giving you nothing .. because the object is no longer valid take a look and play with the cache profile settings .. there is a couple for intranet and extranet or anonymous

SunChero

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top