Robin
2/14/2007 5:34:00 PM
Here is the code:
//test code per msdn forum
string cached = Cache["test"] as string;
if(cached == null)
{
LogTestCacheMessage("Not cached, inserting into cache");
Cache.Insert("test", DateTime.Now.ToString(), null,
DateTime.Now.AddMinutes(5), System.Web.Caching.Cache.NoSlidingExpiration,
System.Web.Caching.CacheItemPriority.NotRemovable, null);
}
else
{
LogTestCacheMessage("Cached: " + cached);
}
Here are the logs.
2/14/2007 9:03:08 AM Not cached, inserting into cache
2/14/2007 9:03:29 AM Not cached, inserting into cache
2/14/2007 9:03:44 AM Cached: 2/14/2007 9:03:29 AM
2/14/2007 9:03:57 AM Cached: 2/14/2007 9:03:29 AM
2/14/2007 9:04:03 AM Cached: 2/14/2007 9:03:29 AM
2/14/2007 9:04:24 AM Cached: 2/14/2007 9:03:29 AM
2/14/2007 9:04:31 AM Cached: 2/14/2007 9:03:08 AM
2/14/2007 9:04:52 AM Cached: 2/14/2007 9:03:29 AM
2/14/2007 9:09:51 AM Not cached, inserting into cache
2/14/2007 9:09:55 AM Not cached, inserting into cache
2/14/2007 9:10:39 AM Cached: 2/14/2007 9:09:55 AM
2/14/2007 9:10:43 AM Not cached, inserting into cache
2/14/2007 9:11:59 AM Not cached, inserting into cache
2/14/2007 9:12:04 AM Cached: 2/14/2007 9:10:43 AM
2/14/2007 9:12:06 AM Cached: 2/14/2007 9:10:43 AM
2/14/2007 9:12:19 AM Cached: 2/14/2007 9:10:43 AM
2/14/2007 9:13:45 AM Not cached, inserting into cache
2/14/2007 9:13:53 AM Cached: 2/14/2007 9:09:55 AM
2/14/2007 9:14:39 AM Cached: 2/14/2007 9:13:45 AM
2/14/2007 9:18:50 AM Not cached, inserting into cache
2/14/2007 9:18:52 AM Not cached, inserting into cache
2/14/2007 9:19:05 AM Not cached, inserting into cache
2/14/2007 9:19:52 AM Cached: 2/14/2007 9:18:52 AM
2/14/2007 9:19:59 AM Cached: 2/14/2007 9:19:05 AM
2/14/2007 9:26:42 AM Not cached, inserting into cache
2/14/2007 9:26:48 AM Not cached, inserting into cache
Thanks.
"Walter Wang [MSFT]" wrote:
> Hi Robin,
>
> Please help me test following simple code on your server:
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> string cached = Cache["test"] as string;
> if (cached == null)
> {
> Response.Write("Not cached, inserting...");
> Cache.Insert("test", DateTime.Now.ToString(), null,
> DateTime.Now.AddMinutes(5), System.Web.Caching.Cache.NoSlidingExpiration,
> System.Web.Caching.CacheItemPriority.NotRemovable, null);
> }
> else
> {
> Response.Write("Cached: " + cached);
> }
> }
>
> Try to visit the page and refresh for several times, and tell me the
> result. Thanks.
>
> Regards,
> Walter Wang (wawang@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>