Powershell command to remove items from the Appfabric cache

Are there powershell commands for:

  • Get list of items in cache
  • Delete specific item
  • Delete all items
  • Change the value for a specific key

I have not seen a good blog or primer to start with Appfabric caching administration.

Thank!

+5
source share
1 answer

Unfortunately, no :-( PowerShell teams are currently targeting a higher level of detail.

But...

You can write your own PowerShell cmdlets so you can add the extra ones you need :-)

, - . . 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, Powershell Import-Module.

+4

All Articles