Create Cache
You can create a cache by following the steps mentioned below.
Step 1: Create Configuration
The first most step in creating a cache requires adding configuration for that cache in config.ncconf of the cache server. This file contains all configurations for the cache.
Local Cache
NCache supports a standalone (non-clustered) cache which resides on a single node. Note that as it is a single server cache, you can not increase its span to multiple servers to raise its transactional capacity. For more detail on Local Caches, refer to the chapter Local Cache.
Open %NCHOME%\config\config.ncconf file on your local machine.
Copy/paste the entire
<cache-config>
section from the example below to the<configuration>
section of config.ncconf file.You can modify this configuration to change the name from myCache to a name of your choice. Each cache should have a unique name.
The rest of the settings are set to their default values for now. These tags will be discussed in detail in successive chapters.
<cache-config cache-name="myCache">
<cache-settings inproc="False">
<logging enable-logs="True" trace-errors="True" trace-debug="False" log-path=""/>
<performance-counters enable-counters="True" snmp-port="0"/>
<cache-notifications item-remove="False" item-add="False" item-update="False"/>
<cleanup interval="15sec"/>
<storage type="heap" cache-size="1024mb"/>
<eviction-policy enabled-eviction="False" default-priority="normal" policy="priority" eviction-ratio="5%"/>
<cache-topology topology="local-cache"/>
<client-death-detection enable="False" grace-interval="60sec"/>
</cache-settings>
</cache-config>
Step 2: Restart NCache Service
For the configuration changes made to take effect, restart NCache Service. Ensure you have enough privileges to restart the service. If the user is not the part of the Administrator's group, make sure to run PowerShell as an administrator, otherwise, you might get an error message stating "Cannot open ncachesvc service on computer".
Execute the following command in PowerShell to restart NCache Service:
Restart-Service -Name NCacheSvc
Verify that the NCache service has successfully started. If it fails to start, the configuration file has a missing tag or a tag is not properly closed.
Step 3: Verify Cache Creation
To verify successful creation of the cache, open PowerShell and use Get-Caches
cmdlet (shipped with NCache) with -Detail
parameter which displays the registered cache name with additional information.
Get-Caches -Detail
For example, if myCache has been successfully created, the list will contain myCache with the status "Stopped". If the list does not display the cache, there might have been some mistake while changing configuration or NCache Service may not have been restarted.
Step 4: Start Cache
Once cache creation has been verified, start the cache on PowerShell using the Start-Cache
cmdlet.
Start-Cache -Name myCache
Step 5: Verify Cache Running
Once the cache is started successfully, you can verify it by running the Get-Caches
command again as you did in STEP 3.
Step 6: Add Local/Remote Client
You can add a local/remote client to your newly created cache.