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, 4886👍, 0💬
Popular Posts:
.NET INTERVIEW QUESTIONS - Did VB6 support multi-threading ? While VB6 supports multiple single-thre...
What Is C Language? The C programming language is a standardized programming language developed in t...
What is the benefit of using #define to declare a constant? Using the #define method of declaring a ...
How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters? Unicode requires 1...
The object that contains all the properties and methods for every ASP.NET page, that is built is .. ...