Update Cache Configuration
NCache lets you change the configuration of cache but these changes will not be effective unless the cache is restarted.
Note
Caches other than the one that needs modifications don't need to be stopped in order for you to change cache configurations. Even when the service is restarted, no other cache processes are stopped.
Step 1: Stop Cache on All Nodes
You need to stop the cache, in case its running, on the local server (in case of local cache) and on all servers in case you are using a clustered cache. Using PowerShell, you can stop the cache by using the following cmdlet.
Stop-Cache <cache-name>
See Stop-Cache for more details.
Step 2: Modify config.ncconf on All Nodes
Cache configuration must remain the same. For example, if you need to change the size of the cache from 1GB to 2GB, then you need to reflect this change for all cache server nodes. In case this cache configuration is not identical for all cache server nodes, you might notice your cache behaving unpredictably.
Change the configurations in config.ncconf as per your requirements.
For instance, in case you need to modify the size of a cache, you will have to update the config.ncconf of the local server machine in case of a local cache and all servers in case of a clustered cache.
You can specify the <cache-size>
by updating the <storage>
tag under the <cache-settings>
tag.
<cache-config>
<cache-settings ...>
...
<storage type="heap" cache-size="1024mb"/>
...
</cache-settings>
</cache-config>
Refer to Configure Cache Settings for more details on how to update cache settings.
Step 3: Restart NCache Service on All Nodes
You will have to restart the NCache service for the changes made in the configuration to take effect.
- Windows:
To be able to restart the service, you need to have administrative privileges. Make sure you run the Windows PowerShell as administrator. If you do not run PowerShell as administrator for updating cache configuration, then you might get an error saying "Cannot open ncachesvc service on computer".
To restart the NCache service, run the following command:
Restart-Service -Name NCacheSvc
Step 4: Start Cache on All Nodes
Start the cache on all servers once the cache configurations have been updated. You can do this through a PowerShell tool Start-Cache.
Start-Cache -Name <cache-name>
See Also
Create a Cache
Remove Cache
Add Server Node
Remove Server Node