using
System;
using System.Collections.Generic;
using System.Runtime.Caching;
namespace EnterpriseLibraryCacheTest
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load( object sender, EventArgs e)
{
if ( ! IsPostBack)
{
TestCache();
}
}
protected void TestCache()
{
// set cache
ObjectCache cache = MemoryCache.Default;
// add cache
List < string > listQuery = new List < string >
{
" 1 " , " 2 "
};
CacheItemPolicy policy = new CacheItemPolicy();
policy.SlidingExpiration = TimeSpan.FromMinutes( 60 );
cache.Set( " myCache " , listQuery, policy);
// get cache
List < string > listResult = (List < string > )cache[ " myCache " ];
foreach ( string ary in listResult)
{
Response.Write(ary);
}
}
}
}
using System.Collections.Generic;
using System.Runtime.Caching;
namespace EnterpriseLibraryCacheTest
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load( object sender, EventArgs e)
{
if ( ! IsPostBack)
{
TestCache();
}
}
protected void TestCache()
{
// set cache
ObjectCache cache = MemoryCache.Default;
// add cache
List < string > listQuery = new List < string >
{
" 1 " , " 2 "
};
CacheItemPolicy policy = new CacheItemPolicy();
policy.SlidingExpiration = TimeSpan.FromMinutes( 60 );
cache.Set( " myCache " , listQuery, policy);
// get cache
List < string > listResult = (List < string > )cache[ " myCache " ];
foreach ( string ary in listResult)
{
Response.Write(ary);
}
}
}
}