Hi, just finished chapter 16 in Imars awesome book and i want to implement caching to my own little project.
I am counting the number of pictures assosiated with a tag, and i want to save the number in my cache. But i am unsure of how to check if the item is in the cache already.
I wanted to use TryCast(and then check for Nothing) but it did not work with Integers :s
Code:
Dim count As Int32 = Nothing
count = Cache(TagN + "Count")
If count = Nothing Then
count = (From ccc In myEnt.TagLinks
Where ccc.Tag.TagName = TagN
Select ccc).Count
Cache.Insert(TagN + "Count", count, Nothing, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(10))
End If
How should i do this? Are there other things in this code snippet i should change?