Name
Cache
Synopsis
HttpCache = Context.Cache
Returns an instance of the Cache
class.
Parameters
-
HttpCache
An Object variable of type
Cache
.
Example
The example retrieves an instance of the Cache
class into a local variable and then adds a value to the cache:
Sub Application_BeginRequest( ) Dim myCache As Cache myCache = Context.Cache myCache.Add("Test", "Test", Nothing, _ System.DateTime.Now.AddHours(1), Nothing, _ CacheItemPriority.High, Nothing) End Sub
Notes
Note that rather than using the Page_Load event, the example above
shows the Application_BeginRequest event handler in
global.asax
; a common use of the Cache property
is to access the cache at points during request processing when the
Cache property of the Page object is not available, such as before
the Page object is instantiated.
Get ASP.NET in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.