マイクロソフト企業倉庫5.0学習ノート(五)
14999 ワード
この文章の具体的な公式解釈は以下のリンクを参照してください。
Microsoft Enterpris Library 5.0ダウンロード住所:http://msdn.microsoft.com/en-us/library/ff664753%28v=PandP.50%29.aspx
Microsoft Enterprise Library 5.0 Dcumentation:http://www.microsoft.com/downloads/details.aspx?FamilyId=bcb166f7-dd 16-488 b-a 152-9845760 d 9 c&displaylang=en
http://entlib.codeplex.com/releases/view/43135:
企業倉庫キャッシュアプリケーションモジュールには、以下の特徴が含まれています。.グラフィックインターフェースを使って企業キャッシュアプリケーションモジュールを設定することができます。 長い間の記憶ユニットを設定したり、独立したメモリや企業ライブラリのデータを使ってアプリケーションモジュールにアクセスしたりしてもいいです。その状態はメモリ内のキャッシュと同期しています。 管理者が管理できる構成は、グループポリシーツールを使用する。 は、カスタム拡張のための期限切れポリシーと記憶ユニットのモジュールを作成することにより、 はスレッドの安全を保証することができます。 ここでは、Microsoft Enterpris Library 5.0のキャッシュアプリケーションモジュールの使い方を紹介します。
1.Microsoft Enterpress Library 5.0をダウンロードしてインストールし、EntLibConfig.exeを実行します。
CodeDemo Download
2.ブロックメニューを選んで、Add Caching Settingsをクリックします。
設定属性の説明:
3.Fileメニューをクリックして、Saveをクリックして、App.co.nfigファイルとして保存します。まずデスクトップに保存して、それを使うことができます。メモ帳でApp.com figを開いたら、次のような内容が見られます。
コード
4.続いてアプリケーションを作成して、私達が配置したキャッシュアプリケーションモジュールを使用します。ここでtestというコンソールアプリケーションを作成して、先ほど保存したApp.com figファイルをプロジェクトフォルダの下にコピーしました。
5.キャッシュ・アプリケーション・モジュールを使用するには、相応のDllファイルを導入する必要があります。ここで導入するのはMicrosoft.Practices.EnterprseLibrary.aching.dllです。App.com figファイルをプロジェクトに追加し、Microsoft.Practices.Entrary.Interprise.Clariccing.とusing Microsoft.Prections.Proctic.Procticess.Processity.Practicess.Practicess.Procticess.Prot.を追加します。
参照を追加:
6.キャッシュ項目を追加して読み取り、下に示すのは一つのstringオブジェクトをキャッシュに保存し、実際のアプリケーションではデータベースから読み出したデータセットを記憶するためによく使われます。
(1) 読み取ったデータはタイプをタイプに変換します。
(2) 読み取りの時は、空の値かどうか確認したほうがいいです。
実行結果:
7.アイテムを削除します。
どうぞ
Microsoft Enterpris Library 5.0ダウンロード住所:http://msdn.microsoft.com/en-us/library/ff664753%28v=PandP.50%29.aspx
Microsoft Enterprise Library 5.0 Dcumentation:http://www.microsoft.com/downloads/details.aspx?FamilyId=bcb166f7-dd 16-488 b-a 152-9845760 d 9 c&displaylang=en
http://entlib.codeplex.com/releases/view/43135:
企業倉庫キャッシュアプリケーションモジュールには、以下の特徴が含まれています。
1.Microsoft Enterpress Library 5.0をダウンロードしてインストールし、EntLibConfig.exeを実行します。
CodeDemo Download
2.ブロックメニューを選んで、Add Caching Settingsをクリックします。
設定属性の説明:
3.Fileメニューをクリックして、Saveをクリックして、App.co.nfigファイルとして保存します。まずデスクトップに保存して、それを使うことができます。メモ帳でApp.com figを開いたら、次のような内容が見られます。
コード
<
configuration
>
<
configSections
>
<
sectionname
="cachingConfiguration"
type
="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings,Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.414.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35"
requirePermission
="true"
/>
</
configSections
>
<
cachingConfigurationdefaultCacheManager
="Cache Manager"
>
<
cacheManagers
>
<
addname
="Cache Manager"
type
="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager,Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.414.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35"
expirationPollFrequencyInSeconds
="60"
maximumElementsInCacheBeforeScavenging
="1000"
numberToRemoveWhenScavenging
="10"
backingStoreName
="NullBackingStore"
/>
</
cacheManagers
>
<
backingStores
>
<
addtype
="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore,Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.414.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name
="NullBackingStore"
/>
</
backingStores
>
</
cachingConfiguration
>
</
configuration
>
4.続いてアプリケーションを作成して、私達が配置したキャッシュアプリケーションモジュールを使用します。ここでtestというコンソールアプリケーションを作成して、先ほど保存したApp.com figファイルをプロジェクトフォルダの下にコピーしました。
5.キャッシュ・アプリケーション・モジュールを使用するには、相応のDllファイルを導入する必要があります。ここで導入するのはMicrosoft.Practices.EnterprseLibrary.aching.dllです。App.com figファイルをプロジェクトに追加し、Microsoft.Practices.Entrary.Interprise.Clariccing.とusing Microsoft.Prections.Proctic.Procticess.Processity.Practicess.Practicess.Procticess.Prot.を追加します。
参照を追加:
using
Microsoft.Practices.EnterpriseLibrary.Caching;
using
Microsoft.Practices.EnterpriseLibrary.Caching.Expirations;
6.キャッシュ項目を追加して読み取り、下に示すのは一つのstringオブジェクトをキャッシュに保存し、実際のアプリケーションではデータベースから読み出したデータセットを記憶するためによく使われます。
(1) 読み取ったデータはタイプをタイプに変換します。
(2) 読み取りの時は、空の値かどうか確認したほうがいいです。
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
Microsoft.Practices.EnterpriseLibrary.Caching;
using
Microsoft.Practices.EnterpriseLibrary.Caching.Expirations;
namespace
test
{
class
Program
{
static
void
Main(
string
[] args)
{
//
CacheManager
CacheManager cacheManager
=
(CacheManager)CacheFactory.GetCacheManager();
//
cacheManager.Add(
"
MyDataReader
"
,
"
123
"
);
//
string
str
=
(String)cacheManager.GetData(
"
MyDataReader
"
);
//
Console.WriteLine(str);
}
}
}
実行結果:
7.アイテムを削除します。
//
cacheManager.Remove(
"
MyDataReader
"
);
どうぞ