D
Dave S
Hi,
I'm trying to use cachedependency to refresh a variable when a config
file in the web application changes, but it doesn't seem to work no matter
what I do.
The code is in the global.asax file on the website and is show below.
The delegate function 'refresher' only seems to fire in debug mode.
The example below has been simplified because I actually want to retrieve
values from the config.xml file when it changes but I need to get this
delegate callback working before I can even think of doing that.
Any ideas what I'm doing wrong ?
Public recache As New CacheItemRemovedCallback(AddressOf refresher)
Public appCache As Cache
Public configFile As String
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the application is started
Dim s As String = "START"
Context.Application("TEST") = s
configFile = Server.MapPath("config.xml")
' use this as a trigger to refresh an application variable
appCache = Context.Cache
appCache.Insert("TEST", _
al, _
New CacheDependency(configFile),
Cache.NoAbsoluteExpiration, _
Cache.NoSlidingExpiration, _
CacheItemPriority.Default, _
recache)
End Sub
Sub refresher(ByVal key As String, ByVal value As Object, ByVal reason
As CacheItemRemovedReason)
Dim s As String = "XXX"
Try
appCache.Insert("TEST", _
s, _
New CacheDependency(configFile), _
Cache.NoAbsoluteExpiration, _
Cache.NoSlidingExpiration, _
CacheItemPriority.Default, _
recache)
Catch ex As Exception
s = "FAIL"
End Try
Context.Application.Set("TEST", s)
End Sub
I'm trying to use cachedependency to refresh a variable when a config
file in the web application changes, but it doesn't seem to work no matter
what I do.
The code is in the global.asax file on the website and is show below.
The delegate function 'refresher' only seems to fire in debug mode.
The example below has been simplified because I actually want to retrieve
values from the config.xml file when it changes but I need to get this
delegate callback working before I can even think of doing that.
Any ideas what I'm doing wrong ?
Public recache As New CacheItemRemovedCallback(AddressOf refresher)
Public appCache As Cache
Public configFile As String
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the application is started
Dim s As String = "START"
Context.Application("TEST") = s
configFile = Server.MapPath("config.xml")
' use this as a trigger to refresh an application variable
appCache = Context.Cache
appCache.Insert("TEST", _
al, _
New CacheDependency(configFile),
Cache.NoAbsoluteExpiration, _
Cache.NoSlidingExpiration, _
CacheItemPriority.Default, _
recache)
End Sub
Sub refresher(ByVal key As String, ByVal value As Object, ByVal reason
As CacheItemRemovedReason)
Dim s As String = "XXX"
Try
appCache.Insert("TEST", _
s, _
New CacheDependency(configFile), _
Cache.NoAbsoluteExpiration, _
Cache.NoSlidingExpiration, _
CacheItemPriority.Default, _
recache)
Catch ex As Exception
s = "FAIL"
End Try
Context.Application.Set("TEST", s)
End Sub