Cache Expiration Doesn't Expire in the given time!
hello all,
I am trying to simulate multi-threading via the cache object. I do this by inserting a simple item into cache with a CacheItemCallback function attached to that cached item such that once that simple item expires, the cacheCallBack function gets called and does the appropriate functionality i specified.
Now to my question.
When we insert this simple Item into cache, i try to tell it to expire in DateTime.AddSeconds(1) which is essentially 1 second, but for some reason, the cacheItemCallBack Function gets called every 1 Minute, not 1 second. Does anyone have any thoughts as to why my cached item won't expire in 1 second like i told it to?
Sample Code:
Dim _Article as new Article()
_Article.Text = "HELLO WORLD"
HttpContext.Current.Cache.Insert( _
"Article-" & Me.JobID, _
_Article, _
Nothing, _
DateTime.Now.AddSeconds(1), _
System.Web.Caching.Cache.NoSlidingExpiration, _
Caching.CacheItemPriority.Low, _
New Caching.CacheItemRemovedCallback(AddressOf RunJobCallBack))
Private Sub RunJobCallBack(ByVal k As String, ByVal v As Object, ByVal r As System.Web.Caching.CacheItemRemovedReason)
' Do some processing once the cached item has expired.
' ...
End Sub
|