Retrieving objects stored within the cache is simple; there are two options for doing so:
Dictionary style-Using patterns similar to that of Session and Application.
Cache.Get() API-The Get() method accepts a single parameter that fetches the
value of the named key.
Given the example used in Section 4.3 that added a dataset into the cache using the key
MyProducts, you could retrieve this value from the Cache:
' Get a value from the cache
<script runat="server">
Sub Page_Load(object As Sender, e As EventArgs)
Dim ds As DataSet
If (Cache("MyProducts") Is Not Nothing) Then ' Uses Dictionary style API
ds = CType(Cache.Get("MyProducts"), DataSet) ' Uses Get() method
End If
End Sub
</script>
Comments
Getting items stored within the cache is very simple. Although both techniques-dictionary
style and Get()-are used in this example, the dictionary style access is the one
most frequently used.
No comments:
Post a Comment