Ver Mensaje Individual
  #2 (permalink)  
Antiguo 06/07/2009, 04:09
chcma
 
Fecha de Ingreso: junio-2003
Ubicación: Asturias
Mensajes: 2.429
Antigüedad: 20 años, 11 meses
Puntos: 7
Respuesta: Problema con caducidad cache

Al final he cambiado el código y lo he dejado asi (Por favor, díganme si es óptimo y hace lo que espero que haga, que es que cuando se elimine la caché, por modificar el fichero, es que se vuelva a generar otra vez !!!)

Código:
        Private Function GetSetXml() As XmlDocument

            Dim pathFicheroXML As String = Server.MapPath("") & "/" & GetUrlRelativa() & "/xmlConfiguracion.xml"

            Try                
                If (Cache.Item("objDocumentoXml") Is Nothing) Then

                    Dim objDocumentoXml As System.Xml.XmlDocument = Utils.IO.XML.GetFicheroXml(pathFicheroXML)
                    Cache.Insert("objDocumentoXml", objDocumentoXml, New System.Web.Caching.CacheDependency(pathFicheroXML), Cache.NoAbsoluteExpiration, TimeSpan.Zero, Caching.CacheItemPriority.NotRemovable, New Caching.CacheItemRemovedCallback(AddressOf CacheEliminada))
                End If

                Return DirectCast(HttpContext.Current.Cache.Item("objDocumentoXml"), XmlDocument)

            Catch exSinsa As ExcepcionesSINSA.ExcepcionesSINSA
                exSinsa.InsertarDesOrigen(Me.GetType(), MethodBase.GetCurrentMethod())
                exSinsa.LogException(0, 54, 40, "ClsPaginaBase.vb", "ClsPaginaBase", "03", System.Net.Dns.GetHostName, Me.IPCliente)

                Return Nothing

            Catch ex As Exception
                Dim objEx As New ExcepcionesSINSA.ExcepcionesSINSA(Me.GetType(), MethodBase.GetCurrentMethod(), _
                                                                   ExcepcionesSINSA.CodigoErrorTabla.ErrorAplicacion, ex, _
                                                                   TipoGravedad.ErrorEjecucion, _
                                                                   ex.Message, TipoError.Pagina, _
                                                                   "Error Cargando XML.", CodigoEstadoPag.SigueEjecucion)
                objEx.LogException(0, 54, 40, "ClsPaginaBase.vb", "ClsPaginaBase", "03", System.Net.Dns.GetHostName, Me.IPCliente)

                Return Nothing
            End Try
        End Function
        Private Sub CacheEliminada(ByVal keyCache As String, ByVal objEnCache As Object, ByVal motivoEliminacion As Caching.CacheItemRemovedReason)

            Me.GetSetXml()
        End Sub
__________________
Charlie.