???? ??? ??????? ????? ????? ??????? ?????? ???????? ???????? ?????? ????? ??? ????? ?? ????? Microsoft ASP.NET. ?????? ????? ?? ??? ??????? ?????? ?? ????? ????
DataSet ?? ????? ??????? ?????? ?? ????? ????? ??? ???? ??? ????? ????? ??????? ?????? ?????? ?????? ??? ??????? ????? ??. ?????? ??? ????? ?? ?????? ????? ??????? ?????? ?? ????? ?? ?????? ???????? ??? ???? ???? ??? "???????" ?? ??? ???????.
???????
- Microsoft Windows 2000 ?? Microsoft Windows XP
- ???? ??????? ???????? ?? Microsoft "(IIS)
- ???? ??? Microsoft .NET
- Microsoft SQL Server
????? ????? ??? ASP.NET
?????? Microsoft Visual C# .NET ????? ???? ??? Microsoft ASP.NET ?????? DataCacher ???????:
- ???? Microsoft Visual Studio .NET.
- ?? ??????? ???? ??? ??? ???? ?? ???? ??? ???????.
- ?? ???? ?????? ????? ???? ? ???? ??? Visual C# ?????? ??? ????? Project ?? ???? ??? ????? ??? ASP.NET ??? ?????.
- ?? ?????? ??????? ???? DataCacher ??? ?? ??? ??????? ?? ???? ??????? WebApplication# ????? ????????? ?? ???? URL. ??? ??? ?????? ?????? ??????, ???? ??? ??? ?????? ?? http://localhost ????? ?????? ??? http://localhost/DataCacher.
????? ????? ???
??????: ?????? ????? ?? ???????? ?? ?????? "????? ???" ????????? ???????? ??????? ?? ??? ??????.
????? ?????? ????? ??????? ?????? ?????:
- ????? "????? ???" ???? ???? DataCacheSample.aspx ??? ??????? ?? Visual Studio .NET:
- ???? ??? ?????? ?????? ??? ???? ????? ?? ???? Explorer.
- ???? ??? ????? ?? ???? ??? ????? WebForm ????.
- ??? DataCacheSample.aspx ????? ???.
- ???? ??? ???.
- ??? ????? ??????? ????? ????? ????? "???????" ??? "?? IDE .NET Studio Visual (???? ??????? ?????????) ? ????? ??" ????? ??? "??? ??????:
- ??????? ????? ????? ???????? ???? ?? "????? ???" ??? ??????.
- ???? ??? ???? ??????. ????? ????? ?????? ??? CreateNewOrCached ?? ?? ?????? ??????? Text ??? ????? ???? ?? ??????.
- ????? ?? "????? ???" ????:
- ?????? ???? ????? ????? ???????? ???? "????? ???" ??? ??? ?????? ?? ???? ???????.
- ???? ??? ???? ??????. ????? ????? ?????? ??? ????? ?? ?? ?????? ??????? Text?????.
- ????? ????? "????? ???":
- ??????? ????? ????? ???????? ???? ????? "????? ???" ??? ?????? ?? ???? ???????.
- ???? ??? ????? ?????. ????? ????? ?????? ??? CacheStatus ?? ?? ?????? ????? ??????? Text.
- ??????? ????? ????? ???????? ???? ???? ???? "????? ???" DataGrid ??? ?????? ?? ???? ???????. ???? ??????? ???? ????? ??????? ????????? DataGrid1 ?? ????? ????? ???? ?????? ???.
????? ????????? ????????
????? ????????? ???????? ?????? ??????? ????? ??????? ?????? ?????? ??????? ????? ??????? ?????? ? ?????? ????? ????? ??????? ???????:
- ???? ??? ?????? ?????? ??? ???? .aspx ??? ?? ???? ??? ??? ????????? ???????? ??? ??? ???? ??????? ????????? ????????.
- ?????? ??? ??? ?????? ???? ?? ????? System.Data.SqlClientSystem.Data ? ?????? ??????? System.Web.Caching ??? ????? ????? ????? ????? ?? ???? ????????? ???????? ???????. ??? ??? ?????? Visual Studio. ????? NET ?????? "????? ???" ????? ?? ????? ????? ??? ?? ????????? ???????? - ??? ?????? ?????? ??? ???:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Web.Caching;
??????: ????? ?????? ??????? ??? ????? ????? ??? ???? ?? ??? ??? ????? ??????? ?????? ?? ????? ??? ???????. - ??? ????? ??????? ????? ????? "?????" ? ???? ????? ??????? ??? ???? CreateNewOrCached ???? ????? CreateNewOrCached_Click ?? ???? ????????? ???????? ???????.
- ?? ?????? ????????? ???????? ??????? ??? ????? CreateNewOrCached_Click:
private void CreateNewOrCached_Click(object sender, System.EventArgs e) {
//Attempt to create a DataSet object from the cache entry with the key "CacheDataSetEmployees"
object CacheDataSetEmployees = (DataSet)Cache.Get("CacheDataSetEmployees");
//Check to see if the object is null
if(CacheDataSetEmployees == null)
{
//Set a value for the cache entry that will serve as the
//key for the dependency to be created on
Cache["SqlPubsEmployees"] = "SomeValue";
//Create the array of cache key item names
string[] keys = new String[1];
keys[0] = "SqlPubsEmployees";
DataSet ds = new DataSet();
//Create the connection and pass in the ConnectionString
SqlConnection MySqlConn = new SqlConnection("Server=kronicas17;Trusted_Connection=Yes;initial catalog=pubs");
//Create the Data Adapter and pass in the command text and connection to use
SqlDataAdapter MySda = new SqlDataAdapter("SELECT TOP 10 * FROM Employee", MySqlConn);
//Populate the DataTable "Employees" in the DataSet
MySda.Fill(ds,"Employee");
//Set the DataGrid's DataSource to the "Employee" DataTable
DataGrid1.DataSource = ds.Tables["Employee"];
//Create a dependency object referencing the array of cachekeys (keys)
CacheDependency MyDependency = new CacheDependency(null, keys);
//Insert the DataSet into Cache with a dependency on MyDependency
Cache.Insert("CacheDataSetEmployees", ds, MyDependency);
MySqlConn.Close();
//Display the status of the DataSet/Cache Entry
CacheStatus.Text = "New Version Created";
}
else
{
//Display the status of the DataSet/Cache Entry
CacheStatus.Text = "Cached Version Used";
//Set the DataSource to the cached version of the DataSet
DataGrid1.DataSource = CacheDataSetEmployees;
}
//Bind the DataGrid to the DataSource
DataGrid1.DataBind();
}
??????: ?? ????? ??? ????? ?????_????_??????? ?? ????????? ???????? ?? ??? ?????? ????? ???? ???? ?? ???? SQL. ?????? ??? ????????? ???????? ????? ???? ???? ??? ?? ???? ???? ????? ?????? SQL Server Pubs ?????. - ??? ??????? ????? ????? ????? ?????? DataCacheSample.aspx ???? ????? ??????? ??? ???? "?????" ???? ??? Remove_Click ?? ???? ????????? ???????? ???????.
- ?? ?????? ????????? ???????? ??????? ??? ????? Remove_Click:
private void Remove_Click(object sender, System.EventArgs e)
{
//Remove the cache item listed in the cachekeys array (keys)
Cache.Remove("SqlPubsEmployees"); //Display the status of the cache item
CacheStatus.Text = "Cache Item Removed";
}
- ??? ?????? ?????? ??? ??? Web.config <system.web> ??? </system.web>:
<identity impersonate=?true? />
- ?? ??????? ???? ???? ??? ??? ???? ???? "????? ???" ???????? ?????? ?????.
- ?? ??????? ???? ?? IDE .NET Studio Visual ???? ??? ????? ?????? ???????.
????? ????????? ????????
- ?????? ????????? ???????? ???? ??? ?????? ?????? ??? ?????? DataCacheSample.aspx ?? "?????? ??????" ??? ?? ???? ??? ??? ?? ??????.
- ???? ??? ???? CreateNewOrCached ??? ??? ??????? CacheStatus "????? ????? ????" ?? ??? ????? ???? ???? DataGrid.
???????: - ???? ??????? ????? ????? ???? ??????? CacheStatus ????? ????? ????? ??????? ?????? CacheDataSetEmployees ?????? ??? ?? ??? ??? ???? ????? ??????? ???? ???? ??? ????? ?????. ?? ??? ??????? ??? ????? DataSet ????? ?????? DataGridDataSet ?? ??? ????? DataSet ??? ????? ??????? ?????? ???????? ????? ????? ??????? ?????? "CacheDataSetEmployees".
- ?? ?????? ??????? ???? ??? ?? ???? ???? ????? ????? ????? ???? CacheDependency ???? ???? MyDependency. ??? ??? ?????? MyDependency ??? ??????? ???? CacheDataSetEmployees ????? ??? ??????? ??? ????? ??????? ?????? ?????? ??????? ??????? ?????. ?? ????? ?????? ??? ????? ???? ??? ??????? ????? ??? ????? ???????? ? ????? ??????? ????? ???? ?? ???????? ??? ????? ??????? ?????? ?????? ??? ??????? ?? ???? ????, ?????.
- ???? ??? ???? CreateNewOrCached ??? ????. ???? ????? CacheStatus "??????? ?????? ???????" ? ???? ??? ??? ??? ?? ??????? DataSet ??????? ??????. ????? ?????? ?? ?? ??? ?? ???????? ??????? ?????? ?? ???? ????? ??? ??????? ???????? ?? ????? ?????? Pubs ???????? ???? ??????? SQL ?? ???? ????. ??? ????? ????? ???? ??? ???? CreateNewOrCached ??? ????. ?????? ?? ??? ??? ????????? ???? ???????. ???? ??? ????? ?? ???? ??? CreateNewOrCached ??? ???? ??????? ????????? ???? ?? ??????? ??? ????? ????????.
- ???? ??? ???? ?????. ???? ????? CacheStatus "????? ????? ????? ??????? ??????". ???? ????? ??????? ?????? ?????? ????? "SqlPubsEmployees" ?????? ??????? ??????? Cache.Remove ?? ????? Remove_Click. ??? ??? ?????? (????? ????? ??? ??? ?????? ??? ?????? ????? ????? ??????? ??????) ?? MyDependency ??? ?????? ? ??? ????? ?????? "CacheDataSetEmployees" ???? ?????? ???????? ????? ????? ?? ??????? ??? MyDependency ?????? ??????? ?????? ??.
- ???? ??? ???? CreateNewOrCached ??? ????. ???? ????? CacheStatus ????? "????? ????? ????" ???? ?? ?????? DataSet based on ?? ??? ?? ??? ?????? ?? ????? ??????? ?????? ??? ????? ?? ?????.
- ?? ????? ????? ?? ??? ??? ???? ?????? DataGrid ??? ????????(SSP) ???????? ??? ??? ????? ?????? DataSet ?? ????? ??????? ??????. ???? ??? ????? ??????? EnableViewState ????? ??? True ???? ???????. ???? ????? ???? ???? ?????? ???????? ?? ??? ?? ????? ??? ?????? ????? ????? ??????? ?????? ?? ????????? ????????. ?????? ??? ????? ???? ???? ?? ???? ???? ?????? ?? ?? ????? ? ????? ????? EnableViewState ??? ???.
??????: ?????? ??? ?????? ?? ???? ??????? ?? ?????? ????? ????? ??????? ?????? (????
???????? ?? ????? ???????? ????????) ???? ?????? ????? ??????? ?????? ????? ???? ?? ??????? ?????? ????? ??????? ?????? ???? ??? ??? ??? ??? ??????? ?? ????? ?? ???? ????? ????? ????? ??????? ?????? (
CacheDataSetEmployees ?? ??? ??????) ?????? ???? ?? ?????? ?????? ??? ??????? ?? ????? ??????? ?????? ?????. ??? ?? ?? ????? ??????? ???????? ?????? ???????????; ?????? ??? ???? ?? ????????? ??? ?????? ??????????? ? ???? ??? "???????" ?? ??? ???????.
??????? ??????? ????????
- ??? ?? ???? ????? ???????? ???? ?? ????? ?? ???? ?????? ????? ??????? ?????? ???????? ?? ??????? ??????? ????? ??????? ??????. ??? ?? ??? ?? ??? ???????? ?????? ???? ??? ??????? ??????? ???? ???? ?? ????? ??????? ??????. ????? ???? ??? ???? ???????? ?? ????? ???????? ???????? ????? ???? ?????? ??? ?? ?? ????? ?????? ??? ??? ????? ????? ??????? ???? ??? ????.
- ???? ?????? ????? ??????? ?????? ??? ?? ????? ???? ??? ??? ????????? ?? ???? CacheDependency.
- ??? ??? ?????? ???? ?? ????? ??????? ?????? ?? ??? ???? ????? ?? ?????? ???????? ???? ??? ??????? ?????? ??? ????? ?????? ?? ????? ??????? ??????.
?????? ??? ???? ?? ????????? ??? ???????
CacheItemRemovedCallback ?????, ???? ???? Microsoft ?????? ??? ?????:
??????: ??????
CacheItemRemovedCallback ????? ????? ?? ????? ??????? ????????? ??? ????? ???? ????? ??????? ?????? ?? ????? ??????? ??????.
????? ?? ????????? ??? ???
CacheDependency ???? ???? Microsoft ?????? ??? ?????:
??????: ???
CacheDependency ????? ?????? ????? ??????? ?????? ???? ?? ???? ??????? ?? ??????? ?? ?????? ???????? ?????? ?? ????? ??????? ?????? ??????? ????? ??.
????? ?? ????????? ??? ?????? ??????? ?????? ???????? ???????? ?? ASP.NET ???? ????? Microsoft .NET Framework SDK ???????:
?????? ??? ??????? ?????? ??? ?????? ??????? ?????? ???????? ???????? ?? ASP.NET ???? ??? ???? ????????? ????????? ??????? ?? "????? ??????? ?? Microsoft:
305140
(http://support.microsoft.com/kb/305140/EN-US/
)
??????? ASP.NET
307225
(http://support.microsoft.com/kb/307225/EN-US/
)
INFO: ???? ??????? ?????? ASP.NET
???? ???????: 308147 - ????? ??? ??????: 15/?????/1428 - ??????: 2.8
????? ???
- Microsoft ASP.NET 1.1
- Microsoft ASP.NET 1.0
- Microsoft Visual C# .NET 2003 Standard Edition
- Microsoft Visual C# .NET 2002 Standard Edition
| kbmt kbcaching kbdatabase kbhowtomaster KB308147 KbMtar |
????? ???????: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????
308147
(http://support.microsoft.com/kb/308147/en-us/
)