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, 4719👍, 0💬
Popular Posts:
Explain all parts of a deployment diagram? Package: It logically groups element of a UML model. Node...
What invokes a thread's run() method? After a thread is started, via its start() method of the Threa...
Which JavaScript file is referenced for validating the validators at the client side ? WebUIValidati...
If we have the following in a Java code: String s="abc"; String s2="abc"; Then what will be output o...
How do you target a specific frame from a hyperlink? Include the name of the frame in the target att...