Enable Read-Through and Write-Behind on a Cache (AppFabric 1.1 Caching)

Before enabling a Microsoft AppFabric 1.1 for Windows Server Caching read-through / write-behind provider on a cache, you must first complete the following two steps:

  1. Extend the DataCacheStoreProvider Class (AppFabric 1.1 Caching)

  2. Deploy a Read-Through / Write-Behind Provider (AppFabric 1.1 Caching)

After these two steps, you are ready to enable the provider on a cache.

Enabling the Provider using Windows PowerShell

The provider can be associated with a cache using the Windows PowerShell commands New-Cache and Set-CacheConfig. These commands support the following parameters that configure read-through / write-behind providers.

Parameter Type Description

ProviderType

string

The fully qualified name of the provider assembly type. This provider implements the write-behind and read-through features. The name is case-sensitive.

ProviderSettings

hashtable

One or more key/value pairs that specify configuration settings, such as connection information, for the provider.

ReadThroughEnabled

string

Use this parameter to enable the read-through feature. By default this is set to false.

WriteBehindEnabled

string

Use this parameter to enable the write-behind feature. By default, this is set to false.

WriteBehindInterval

integer

The number of seconds by which time a cache item should be written to the provider after being written to the cache.

WriteBehindRetryCount

integer

The maximum number of connection retries to the write-behind provider. (a value of -1 results in infinite retries).

WriteBehindRetryInterval

integer

The retry interval, in seconds, to wait between retry attempts in the case of a connection failure to the write-behind provider.

Note that Set-CacheConfig does not require the cache cluster to be stopped for these provider changes if the refreshNow switch is used. This is not true of other cache configuration settings changes which require stopping the cache cluster first.

The ProviderType parameter uses a fully qualified name of the class that implements the provider. One way to find the fully qualified name of the assembly is to use the gacutil.exe tool to search the Global Assembly Cache for the registered assembly. This is shown in the following example.

gacutil.exe /l RTProvider

This would return the fully qualified name of the assembly in the Global Assembly Cache, such as the following:

RTProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=80e2cb5f6ba933f0, processorArchitecture=MSIL

To that you would need only to append the qualified class name. For example, if the class name were Provider, the ProviderType parameter in this example would be set to the following string.

RTProvider.Provider, RTProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=80e2cb5f6ba933f0

Note that the ProviderSettings parameter is set to one or more key/value pairs that are custom to the provider. This parameter is only required if the provider requires these settings.

Example

The following example creates a new cache named Cache1 that enables read-through and write-behind using a provider, RTProvider.

New-Cache Cache1 -ReadThroughEnabled true -WriteBehindEnabled true -WriteBehindInterval 60 -ProviderType "RTProvider.Provider, RTProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=80e2cb5f6ba933f0" -ProviderSettings @{"setting1"="value1";"setting2"="value2"}

Note that the ProviderSettings parameter passes two key/value pair settings in a syntax that Windows Powershell uses for specifying hashtables.

Other Considerations

  • If you get an error when you enable the provider, there is a possibility that the provider did not successfully register. Verify that the provider is registered on all cache hosts and that you specified the fully qualified name correctly.

  • If you update a provider DLL in the Global Assembly Cache on each cache host, the cache cluster will not use the updated version until the caching service is restarted with the Restart-CacheCluster or Start-CacheHost Windows PowerShell commands.

  • The DataCacheItem objects are stored in the cache cluster in a serialized form. If the provider must deserialize the data stored in the DataCacheItem, then the assemblies associated with those serialized objects must also be in the Global Assembly Cache on the cache hosts.

See Also

Concepts

Extend the DataCacheStoreProvider Class (AppFabric 1.1 Caching)
Deploy a Read-Through / Write-Behind Provider (AppFabric 1.1 Caching)

  2012-09-12