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, 4669👍, 0💬
Popular Posts:
What are the five levels in CMMI? There are five levels of the CMM. According to the SEI, Level 1 – ...
What is the quickest sorting method to use? The answer depends on what you mean by quickest. For mos...
.NET INTERVIEW QUESTIONS - Did VB6 support multi-threading ? While VB6 supports multiple single-thre...
Describe in detail Basic of SAO architecture of Remoting? For these types of questions interviewer e...
How To Wirte a Simple JUnit Test Class? This is a common test in a job interview. You should be able...