To preserve the cache data in some persistent storage, you can configure write-through providers for a cache. By using write through provider, the cached data and data added/updated/removed is synchronized with a data source.
If write-behind option is enabled, then all of the data source operations are queued up on server side and performed in the background. There are multiple settings, which can be used to optimize the write-through provider to fulfill the user requirements.
Add/Remove Write Through Providers
For NCache Professional Edition, you can add write-through providers using Windows PowerShell.
Step 1: Stop Cache
Stop the cache on all servers before updating the cache settings through Windows PowerShell using the Stop-Cache cmdlet.
Stop-Cache -Name demoClusteredCache
Add Write-Through / Write-Behind Providers
Add the write-through or write-behind providers using the Add-BackingSource cmdlet.
The following example adds write-thru provider
sqlwriter to the cache demoClusteredCache.
Add-BackingSource -CacheName demoClusteredCache -AssemblyPath C:\WriteThru.dll -Class WriteThru.Writer -ProviderName sqlwriter -WriteThru
The following example adds write-thru provider with write-behind enabled for the cache demoClusteredCache.
Add-BackingSource -CacheName demoClusteredCache -AssemblyPath C:\WriteThru.dll -Class WriteThru.Writer -ProviderName sqlwriter -WriteThru -isBatching
Remove Write-Through / Write-Behind Providers
Remove-BackingSource cmdlet removes the pre-configured write-thru or write-behind from the cache.
The following example removes the pre-configured write-thru providers named
sqlwriter from the cache demoClusteredCache as well as write-behind providers if configured.
Remove-BackingSource -CacheName demoClusteredCache -ProviderName sqlwriter –WriteThru
Step 3: Start Cache
Start the cache on all servers through Windows PowerShell using the Start-Cache cmdlet.
Start-Cache -Name demoClusteredCache