Data is lost from my asp.net cache

19 09 2011

A strange experience it was; losing data from the Asp.net cache.
I was refactoring some code which was used frequently in my Asp.net code, and all it did was getting a non-volatile list of items from the database. A good candidate for some caching I thought.

So I created the caching code, hit F5 and started the program.
And guess what? All new errors occurred.

While debugging I found out that the first moment I put in ten items for the cachekey, and later on I only got five out when I asked for the same data.
So what is this? A bug in the cache in .Net?
Most likely not, so I investigated the rest of the code.

And what turned out to be the case?
One function getting the data from the cache actually removed items from the list.
That is perfectly ok if the next code gets a fresh result from the database, but not if the items are removed from a list which is actually in cache.


Acties

Informatie

Geef een reactie

Fill in your details below or click an icon to log in:

WordPress.com logo

Je reageert onder je WordPress.com account. Log Out / Bijwerken )

Twitter-afbeelding

Je reageert onder je Twitter account. Log Out / Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log Out / Bijwerken )

Verbinden met %s




Follow

Get every new post delivered to your Inbox.