Based on a datetime value I insert values into the cache:
Dim Value1 As String = "value1"
Dim Value2 As String = "value2"
Dim Key1 As String = "Key" & New Date(2014, 1, 1, 1, 1, 0).ToString
Dim Key2 As String = "Key" & New Date(2014, 1, 1, 1, 2, 0).ToString
HttpContext.Current.Cache.Insert(Key1, Value1)
HttpContext.Current.Cache.Insert(Key2, Value2)
Is it possible to invalidate those cache items using another cache item as CacheDependency?
I tried the following, but this doesn't work:
Dim Keys As String() = New String(0) {}
Keys(0) = "OtherKey"
Dim MyDependency As New System.Web.Caching.CacheDependency(Nothing, Keys)
HttpContext.Current.Cache.Insert(Key1, Value1, MyDependency)
HttpContext.Current.Cache.Insert(Key2, Value2, MyDependency)
'To clear all cache items:
HttpContext.Current.Cache.Remove("OtherKey")
When I use this (without the remove statement), the items never can be found in the cache. What am I doing wrong here?