WebMethodAttribute.CacheDuration プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > WebMethodAttribute.CacheDuration プロパティの意味・解説 

WebMethodAttribute.CacheDuration プロパティ

応答キャッシュ内に保持する秒数を取得または設定します

名前空間: System.Web.Services
アセンブリ: System.Web.Services (system.web.services.dll 内)
構文構文

Dim instance As WebMethodAttribute
Dim value As Integer

value = instance.CacheDuration

instance.CacheDuration = value
public int CacheDuration { get;
 set; }
public:
property int CacheDuration {
    int get ();
    void set (int value);
}
/** @property */
public int get_CacheDuration ()

/** @property */
public void set_CacheDuration (int
 value)
public function get CacheDuration
 () : int

public function set CacheDuration
 (value : int)

プロパティ
応答キャッシュ内に保持する秒数。既定値は 0 です。応答キャッシュされていないことを示します

解説解説
使用例使用例

ServiceUsage XML Web サービス メソッド呼び出した結果を、キャッシュ内に 60 秒格納する例を次に示します。その 60 秒間に、XML Web サービス クライアントServiceUsage XML Web サービス メソッド実行すると、常に同じ結果返されます。

<%@ WebService Language="VB" Class="Counter"
 %>

Imports System.Web.Services
Imports System
Imports System.Web

Public Class Counter
    Inherits WebService  

    <WebMethod(Description := "Number of times this service
 has been accessed", _
        CacheDuration := 60, _
        MessageName := "ServiceUsage")> _
    Public Function ServiceUsage() As
 Integer
        
        ' If the XML Web service has not been accessed, initialize it
 to 1.
        If Application("MyServiceUsage")
 Is Nothing Then
            Application("MyServiceUsage") = 1
        Else
            ' Increment the usage count.
            Application("MyServiceUsage") = CInt(Application("MyServiceUsage"))
 + 1
        End If
        
        ' Return the usage count.
        Return CInt(Application("MyServiceUsage"))
    End Function
End Class

<%@ WebService Language="C#" Class="Counter" %>

using System.Web.Services;
using System;
using System.Web;

public class Counter : WebService {
     
     [ WebMethod(Description="Number of times this service
 has been accessed",
     CacheDuration=60,MessageName="ServiceUsage") ]
     public int ServiceUsage() {
          // If the XML Web service has not been accessed, initialize
 it to 1.
          if (Application["MyServiceUsage"] == null)
 {
              Application["MyServiceUsage"] = 1;
          }
          else {
              // Increment the usage count.
              Application["MyServiceUsage"] = ((int)
 Application["MyServiceUsage"]) + 1;
          }

          // Return the usage count.     
          return  (int) Application["MyServiceUsage"];
     }
}

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebMethodAttribute クラス
WebMethodAttribute メンバ
System.Web.Services 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

WebMethodAttribute.CacheDuration プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



WebMethodAttribute.CacheDuration プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS