HttpResponse.AddCacheItemDependencies 메서드

정의

캐시에 있는 다른 항목에 종속된 캐시된 응답의 유효성을 검사합니다.

오버로드

AddCacheItemDependencies(ArrayList)

캐시에 있는 다른 항목에 종속된 캐시된 응답의 유효성을 검사합니다.

AddCacheItemDependencies(String[])

캐시에 있는 다른 항목에 종속된 캐시된 항목의 유효성을 검사합니다.

AddCacheItemDependencies(ArrayList)

캐시에 있는 다른 항목에 종속된 캐시된 응답의 유효성을 검사합니다.

public:
 void AddCacheItemDependencies(System::Collections::ArrayList ^ cacheKeys);
public void AddCacheItemDependencies (System.Collections.ArrayList cacheKeys);
member this.AddCacheItemDependencies : System.Collections.ArrayList -> unit
Public Sub AddCacheItemDependencies (cacheKeys As ArrayList)

매개 변수

cacheKeys
ArrayList

현재 캐시된 응답이 종속된 항목의 키가 들어 있는 ArrayList입니다.

예제

다음 예제에서는 출력 캐시되는 ASP.NET 페이지를 사용하는 방법을 보여 줍니다. 페이지의 코드는 개체에 ArrayList 저장된 항목과 연결된 키의 개체를 Cache 만듭니다. 다음으로, 코드는 메서드에 대한 호출 AddCacheItemDependencies 에서 를 매개 변수로 전달합니다ArrayList. 이렇게 하면 변경 내용에 지정된 파일이 있으면 출력 캐시된 ArrayList 응답이 유효하지 않습니다.

<%@ Page Language="C#" %>
<%@ outputcache duration="30" varybyparam="none" %>
<%@ Import namespace="Samples.AspNet.CS" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="Server">
    private void Page_Load(object sender, System.EventArgs e)
    {

        // Create an array list that
        // contains the keys for two
        // items stored in the Cache object.
        ArrayList deps = new ArrayList();
        deps.Add("bookData");
        deps.Add("authorData");
    
        // Make the page invalid if either of the
        // cached items change or expire.        
        Response.AddCacheItemDependencies(deps);

        // Populate the DataGrids.
        dgAuthors.DataSource = DataHelper.GetAuthorData();
        dgAuthors.DataBind();

        dgBooks.DataSource = DataHelper.GetBookData();
        dgBooks.DataBind();

        lblOutputCacheMsg.Text = DateTime.Now.ToString();

    }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Cache Item Dependencies</title> 
</head>
<body>
    <form id="Form1" method="post" runat="server">
        <table>
            <tbody>
                <tr>
                    <th style="WIDTH: 118px">
                        Authors</th>
                    <td>
                        <asp:DataGrid id="dgAuthors" runat="server"></asp:DataGrid>
                    </td>
                </tr>
                <tr>
                    <th style="WIDTH: 118px">
                        Books</th>
                    <td>
                        <asp:DataGrid id="dgBooks" runat="server"></asp:DataGrid>
                    </td>
                </tr>
                <tr>
                    <td style="WIDTH: 118px">
                        The page was generated at:</td>
                    <td>
                        <asp:Label id="lblOutputCacheMsg" runat="server"></asp:Label>
                    </td>
                </tr>
            </tbody>
        </table>
    </form>
</body>
</html>
<%@ Page Language="vb" %>
<%@ outputcache duration="30" varybyparam="none" %>
<%@ Import namespace="Samples.AspNet.VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

    Private Sub Page_Load(sender As Object, e As System.EventArgs)
       ' Create an array list that
       ' contains the keys for two
       ' items stored in the Cache object.
       Dim deps As New ArrayList()
       deps.Add("bookData")
       deps.Add("authorData")
    
       ' Make the page invalid if either of the
       ' cached items change or expire.
       Response.AddCacheItemDependencies(deps)
    
       ' Populate the DataGrids.
       dgAuthors.DataSource = DataHelper.GetAuthorData()
       dgAuthors.DataBind()
    
       dgBooks.DataSource = DataHelper.GetBookData()
       dgBooks.DataBind()
    
       lblOutputCacheMsg.Text = DateTime.Now.ToString()
    End Sub

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Cache Item Dependencies</title> 
</head>
<body>
    <form id="Form1" method="post" runat="server">
        <table>
            <tbody>
                <tr>
                    <th style="WIDTH: 118px">
                        Authors</th>
                    <td>
                        <asp:DataGrid id="dgAuthors" runat="server"></asp:DataGrid>
                    </td>
                </tr>
                <tr>
                    <th style="WIDTH: 118px">
                        Books</th>
                    <td>
                        <asp:DataGrid id="dgBooks" runat="server"></asp:DataGrid>
                    </td>
                </tr>
                <tr>
                    <td style="WIDTH: 118px">
                        The page was generated at:</td>
                    <td>
                        <asp:Label id="lblOutputCacheMsg" runat="server"></asp:Label>
                    </td>
                </tr>
            </tbody>
        </table>
    </form>
</body>
</html>

설명

매개 변수에서 cacheKeys 참조된 항목이 캐시에서 제거되면 현재 항목의 캐시된 응답이 유효하지 않습니다.

추가 정보

적용 대상

AddCacheItemDependencies(String[])

캐시에 있는 다른 항목에 종속된 캐시된 항목의 유효성을 검사합니다.

public:
 void AddCacheItemDependencies(cli::array <System::String ^> ^ cacheKeys);
public void AddCacheItemDependencies (string[] cacheKeys);
member this.AddCacheItemDependencies : string[] -> unit
Public Sub AddCacheItemDependencies (cacheKeys As String())

매개 변수

cacheKeys
String[]

캐시된 응답이 종속된 항목 키의 배열입니다.

설명

cacheKey의 가 캐시에서 제거되면 현재 항목의 캐시된 응답이 유효하지 않습니다.

추가 정보

적용 대상