Configuring Write-Through Cache Provider
To preserve the cache data in some persistent storage, you can configure a Write-Through provider for a cache. By using the Write-Through provider, the cached data and data added/updated/removed are synchronized with a data source.
Important
For Java, before deploying your JAR files, ensure that your Environment Variable for Java Home is set and have the appropriate JDK installed as discussed in the NCache Installation Guide.
Configuring Write-Through Cache Provider: Using the NCache Management Center
Launch the NCache Management Center by browsing to http://localhost:8251 or
<server-ip>:8251
for Windows and Linux.In the left navigation bar, click on Clustered Caches or Local Caches, based on the cache to which the query index will be added. Against the cache name, click on View Details.
Make sure that the cache is stopped.
This opens up the detailed configuration page for the cache. Go to the Advanced Settings tab and click on Backing Source in the left bar.
Check the Enable Write Through box. Choose to add a provider.
A new page will open up. Enter the Provider Name in the text box and then click on the Browse button to browse for assembly implementing the WriteThruProvider interface. Select the class name from the drop-down list.
Select the required Write-Through provider. You can also provide the values to your Write-Through provider class, if required. Specify the parameter name in the Parameter field and its value against it under the Value field.
Note
These parameters, along with their assigned values, are passed to the selected Write-Through provider when it is initialized on cache start. Providing the parameters is optional.
Click OK.
The selected provider class will be listed in the Read-Through provider list in the Backing Source tab.
Deploy the Write-Through provider assembly along with its dependent assemblies if any. Click on the Deploy Backing Source Provider button at the bottom left of the Backing Source tab. Browse for the required assemblies, select all of the required assemblies, and click Open.
- After applying all the changes click on Save Changes.
Note
If there is a change in provider code, and you have to redeploy the provider, make sure to restart the NCache Execution Service for the changes to take effect.
Note
While using the NCache Execution Service please ensure that the user has the administrative rights.
Configuring Write-Through Cache Provider Using Command Line Tools
Configure Write-Through
The add-backingsource tool enables users to configure backing source (Read-Through and Write-Through) providers for the specified cache.
This command configures writer1 as the Write-Through provider on demoCache using the executable jar.
add-backingsource -cachename demoCache -assemblypath /usr/BackingSourceProviders-1.0.jar -class com.alachisoft.ncache.WriteThru.SampleProvider -providername writer1 -writethru
Remove Write-Through
The remove-backingsource tool removes the preconfigured backing source providers (Read-Through or Write-Through) from the cache or a specified server.
The following command removes the preconfigured Write-Through provider from the demoCache existing on server 20.200.20.39.
remove-backingsource -cachename demoCache -providername writer1 -writethru -server 20.200.20.39
See Also
Read-Through Provider
Write-Through Provider for Write-Behind Operations
Deploy Providers
Add Test Data