ak3nat0n
ak3nat0n

Reputation: 6288

Storing Null value in asp.net cache

This question is somehow related to one that I found here. In order to avoid round trip to the database I am caching the database output but in case of a null value, asp.net cannot make the difference between a value not set and an actual NULL value. I was wondering if instead of checking for the cache value for a specified key , we could check if a key is in the cache . Maybe there is a way to get what keys are in the cache instead of looking for values. If not I would like to know how you would typically cache such data or if in fact caching it makes no sense. Thank you.

Upvotes: 1

Views: 590

Answers (1)

Christian Hayter
Christian Hayter

Reputation: 31071

I suggest you access the cache through your own wrapper function that converts a null into a DBNull.Value before storing.

Upvotes: 1

Related Questions