Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
P)Can you show a simple code showing file dependency in cache
P)Can you show a simple code showing file dependency in cache ?
✍: Guest
Partial Class Default_aspx Public Sub displayAnnouncement() Dim announcement As String If Cache(“announcement”) Is Nothing Then Dim file As New _ System.IO.StreamReader _ (Server.MapPath(“announcement.txt”)) announcement = file.ReadToEnd file.Close() Dim depends As New _ System.Web.Caching.CacheDependency _ (Server.MapPath(“announcement.txt”)) Cache.Insert(“announcement”, announcement, depends) End If Response.Write(CType(Cache(“announcement”), String)) End Sub Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init displayAnnouncement() End Sub End Class
Above given method displayAnnouncement() displays banner text from Announcement.txt file which is lying in application path of the web directory. Above method first checks whether the Cache object is nothing, if the cache object is nothing then it moves further to load the cache data from the file. Whenever the file data changes the cache object is removed and set to nothing.
2007-10-23, 4607👍, 0💬
Popular Posts:
Does .NET support UNICODE and how do you know it supports? Yes .NET definitely supports UNICODE. Try...
How To Recover a Dropped Index? - Oracle DBA FAQ - Managing Oracle Table Indexes If you have the rec...
How To Use "IN OUT" Parameter Properly? - Oracle DBA FAQ - Creating Your Own PL/SQL Procedures and F...
How To Join a List of Keys with a List of Values into an Array? - PHP Script Tips - PHP Built-in Fun...
Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars in this example?...