Using Cache on C# ( VB code included)
<p>How can I use web server cache in a similar way as the following VB code does:</p>

<pre><code>   ////  FindData() returns real data
   //// FindCached() returns from cache (kept 20 minute)

    Protected Function RegisterCachedData(ByVal id As String) As Integer
        Dim onCacheRemove As CacheItemRemovedCallback
        onCacheRemove = New CacheItemRemovedCallback(AddressOf Me.CheckCallback)
        Cache.Insert("AverageData", FindData(1), Nothing, DateTime.Now.AddMinutes(20), TimeSpan.Zero, 1, onCacheRemove)
    End Function

    Sub CheckCallback(ByVal str As String, ByVal obj As Object, ByVal reason As CacheItemRemovedReason)
        RegisterCachedData(0)
    End Sub

   Protected Function FindCached() As Integer
        If Cache.Get("AverageData") Is Nothing Then RegisterCachedData(0)
        Return Cache.Get("AverageData")
    End Function
</code></pre>
