The Cache State

The ASP.NET Cache has the same scope of Application, meaning that both can be accessed by all page requests. The primary difference is that Cache enables holding information in memory, which avoids the need of re-creating and retrieving objects. This is good if you want to maintain updatable objects but could cause overhead (always considering that the bigger the amount of data to transfer, the lower the performance) because it requires memory. So, it should be used only when needed or when you ensure that performance is acceptable. The following is an example of storing and retrieving information with Cache:

Cache("MyUpdatableDataKey") = "My updatable data"Dim myUpdatableData As String = CStr(Cache("MyUpdatableDataKey")) ...

Get Visual Basic 2015 Unleashed 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.