Partial Class Default_aspx
Public Sub display Announcement()
Dim announcement As String
If Cache(“announcement”) Is Nothing Then
Dim file As New _
announcement = file.ReadToEnd
Dim depends As New _
Cache.Insert(“announcement”, announcement, depends)
Private Sub Page_Init(ByVal sender As Object, By Val e As System.EventArgs) Handles Me. nit
Note: - Above source code can be obtained from CD in “CacheSample” folder.”Announcement.txt” is in the same folder which you can play around to see the results.
Above given method display Announcement() 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.
Asked In: Many Interviews |