ADO.NET Provider for SAP Gateway

Build 23.0.8839

データの自動キャッシュ

クエリごとにキャッシュを再構築したくない場合は、データを自動的にキャッシュすると便利です。初めてデータをクエリすると、本製品 はバックグラウンドで自動的にキャッシュを初期化して構築します。AutoCache = true の場合、本製品 は後続のクエリ実行にキャッシュを使用するため、応答時間が短縮されます。

自動キャッシュの設定

SampleTable_1 テーブルのキャッシュ

次の例は、接続文字列のCacheLocation プロパティで指定されたファイルのSampleTable_1 テーブルをキャッシュします。

C#

String connectionString = "Cache Location=C:\\cache.db;AutoCache=true;InitiateOAuth=GETANDREFRESH;User=user;Password=password;URL=https://sapes5.sapdevcenter.com/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/";
using (SAPGatewayConnection connection = new SAPGatewayConnection(connectionString)) {
  SAPGatewayCommand cmd = new SAPGatewayCommand("SELECT Id, Column1 FROM SampleTable_1 WHERE Column2 = 'Bob'", connection);
  SAPGatewayDataReader rdr = cmd.ExecuteReader();
  while (rdr.Read()) {
    Console.WriteLine("Read and cached the row with Id " + rdr["Id"]);
  }
}

VB.NET

Dim connectionString As [String] = "Cache Location=C:\\cache.db;AutoCache=true;InitiateOAuth=GETANDREFRESH;User=user;Password=password;URL=https://sapes5.sapdevcenter.com/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/"
Using connection As New SAPGatewayConnection(connectionString)
  Dim cmd As New SAPGatewayCommand("SELECT Id, Column1 FROM SampleTable_1 WHERE Column2 = 'Bob'", connection)
  Dim rdr As SAPGatewayDataReader = cmd.ExecuteReader()
  While rdr.Read()
	  Console.WriteLine("Read and cached the row with Id " + rdr("Id"))
  End While
End Using

一般的なユースケース

データを自動的にキャッシュする一般的な用途は、レポートの作成やビジュアライゼーションの作成など、ライブデータソースに繰り返し要求を行うときのドライバーのパフォーマンスを向上させることです。自動キャッシュが有効になっていると、同じデータに対する繰り返しの要求は短期間で実行されますが、"ライブ"データと見なされる許容範囲内(CacheTolerance)になります。

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 23.0.8839