Create a Cache in Linux
NCache Open Source edition allows you to create the following caches:
- Local Cache (meaning a standalone cache)
- Partitioned Cache
- Replicated Cache
For other caching topologies, please download and use NCache Enterprise. See more details on edition comparison between NCache Open Source, Professional and Enterprise. We’ll create a Partitioned Cache here.
Make sure NCache Service is started. If it is not started, type the following command in PowerShell:
> sudo systemctl start ncached
Step 1: Modify config.ncconf to Create Partitioned Cache
Do the following (please note that
/opt/ncache/ is where NCache is installed).
Open /opt/ncache/config/config.ncconf file.
Copy/paste the entire
<cache-config>section from the example below to the
<configuration>section of config.ncconf file.
Cache with the specified name should not exist on the server; otherwise you get an error message that this cache already exists on this server.
<cache-config cache-name="demoClusteredCache"> <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"/> <storage type="heap" cache-size="1024mb"/> <eviction-policy default-priority="normal" eviction-ratio="5%"/> <cache-topology topology="partitioned"> <cluster-settings operation-timeout="60sec" stats-repl-interval="60sec" use-heart-beat="False"> <cluster-connection-settings port-range="1" connection-retries="2" connection-retry-interval="2secs" cluster-port="7804"/> </cluster-settings> </cache-topology> </cache-settings> <cache-deployment> <servers> <server-node ip="184.108.40.206"/> </servers> </cache-deployment> </cache-config>
Make sure your
cache-nameis unique within config.ncconf which contains multiple cache definitions.
Replace the IP address given in
<cache-deployment>section with the IP-addresses of all your cache servers.
cluster-portmust be unique and same on all cache servers. You can change it to another TCP port in case of a conflict.
This example uses Partitioned Cache. You can change this to Replicated Cache by changing the value of
The configuration creates a single server cache. If you want to add more servers, add a
<cache-deployment>with the IP address of the new server.
Copy this config.ncconf to all cache servers.
Step 2: Restart NCache Service on Each Cache Server
Anytime you modify config.ncconf, you must restart NCache Service on all cache servers. Do the following in PowerShell:
> sudo systemctl restart ncached
Step 3: Verify Cache Creation on All Cache Servers
To verify that you’ve created the cache successfully, please type the following command in PowerShell on all cache servers:
This command displays all the registered caches on that server. If you have successfully configured your cache, the list should contain demoClusteredCache with status 'Stopped'. If you can't see demoClusteredCache in the list, you must have made some mistake in STEP 1 or you have not restarted NCache service as explained in STEP 2.
Step 4: Start Cache on Each Cache Server
To start the cache, please type the following command in PowerShell on all cache servers:
Start-Cache –Name demoClusteredCache
Successful cache start will be prompted on the terminal.
Step 5: Verify That Cache is Started and Cluster is Formed
To verify whether cluster is formed between nodes, run the following command in PowerShell:
This command gives a detailed status of all caches registered on the cache server. You should see that demoClusteredCache has a Cluster-size of 1 with IP address of the cache server listed with it. The output also displays the Item Count, which at this stage should be 0.