5

次のPowerShellコマンドはありますか?

  1. キャッシュ内のアイテムのリストを取得します
  2. 特定のアイテムを削除する
  3. すべてのアイテムを削除します
  4. 特定のキーの値を変更する

初心者がAppfabricキャッシング管理を開始するための優れたブログやチュートリアルを見つけたことがありません。

ありがとう!

4

1 に答える 1

4

残念ながらそうではありません:-(現在、PowerShellコマンドはより高いレベルの粒度を対象としています。

でも...

独自のPowerShellコマンドレットを作成できるため、必要なコマンドレットを追加できます:-)

カスタムコマンドレットの作成に関する情報はWeb上にたくさんありますが、大まかなガイドとしては次のようになります。選択した言語で新しいクラスライブラリプロジェクトを構築します。System.Management.Automation.dllへの参照を追加します。これはC:\ Program Files \ Reference Assemblies \ Microsoft \ PowerShell\1.0にあります。属性を継承し、持つクラスを作成Cmdlet ますCmdlet。ProcessRecordメソッドをオーバーライドし、必要なことを実行するためのコードを追加します。Powershellからパラメーターを渡すには、クラスにプロパティを追加し、それらをParameter属性でマークする必要があります。次のようになります。

Imports System.Management.Automation 
Imports Microsoft.ApplicationServer.Caching

<Cmdlet(VerbsCommon.Remove, "CacheItem")> _
Public Class RemoveCacheItem
    Inherits Cmdlet

    Private mCacheName As String
    Private mItemKey As String

    <Parameter(Mandatory:=True, Position:=1)> _
    Public Property CacheName() As String
        Get
            Return mCacheName
        End Get
        Set(ByVal value As String)
            mCacheName = value
        End Set
    End Property

    <Parameter(Mandatory:=True, Position:=2)> _
    Public Property ItemKey() As String
        Get
            Return mItemKey
        End Get
        Set(ByVal value As String)
            mItemKey = value
        End Set
    End Property

    Protected Overrides Sub ProcessRecord()

        MyBase.ProcessRecord()

        Dim factory As DataCacheFactory
        Dim cache As DataCache

        Try
            factory = New DataCacheFactory

            cache = factory.GetCache(Me.CacheName)

            Call cache.Remove(Me.ItemKey)
        Catch ex As Exception
            Throw
        Finally
            cache = Nothing
            factory = Nothing
        End Try

    End Sub

End Class

DLLを作成したら、Import-Moduleコマンドレットを使用してPowershellに追加できます。

于 2010-04-02T22:59:35.047 に答える