Create a Distributed Cache with Persistence
This section will demonstrate how you can create a distributed cache with persistence through the NCache Web Manager and PowerShell.
Note
A distributed cache with persistence supports only partitioned topologies and local (OutProc) caches.
Using NCache Web Manager
Launch NCache Web Manager by browsing to http://localhost:8251 or
<server-ip>:8251
on Windows and Linux.In the left navigation bar, click on Clustered Caches. This opens up the Clustered Caches page at
<server-ip>:8251/ClusteredCaches/
.To create a new distributed cache with persistence, click on New.
- From the In-Memory Store Type dropdown menu, select Distributed Cache with Persistence and specify the name of your cache. Click Next.
Note
A distributed cache with persistence supports JSON serialization only.
- Select the caching topology and advanced options like Operation timeout and Statistic replication interval. Click Next.
Note
A distributed cache with persistence supports the Partitioned and Partition-Replica Topologies only.
- Specify the Cache Partition Size and add your cluster nodes by providing the Server Node IP or Host Name and clicking on Add Node button. To add more nodes, click Add Node. Once all the required nodes are added, click Next.
Warning
If a cache with the specified name already exists, you are prompted with an error message.
- Next, you need to provide the persistence store settings for this cache on Persistence Settings page. Choose New Store against the Select Store label. Specify the name of your store against Store Name label. For connection information, provide the UNC Path, User Name, and Password. Once done, click on Test Connection. If the connection to your persistence store has been successfully tested, you will receive a success notification. Click Next.
Important
NCache Persistence requires a shared path that is accessible from all nodes. Make sure that all nodes have read and write access to the shared path.
Warning
Unless the connection to the persistence store has been tested successfully, you can not proceed further with the cache creation process.
- Change the Cluster Port and Port Range if required. Enable pipelining for the cache if required by checking the Enable Pipelining checkbox. Set the Batch Interval for the duration after which the commands will be transmitted over the network in microseconds. Click Next.
- If you want to enable encryption and compression, check the Enable Encryption and Enable Compression checkboxes. If enabled, set the Providers and Key for encryption and Threshold Size for compression. Click Next.
Note
If you want to use an existing store with encryption while creating a new cache, then encryption must be enabled on the new cache and vice versa. If the existing store was encrypted, the encryption credentials (provider and key) need to be the same as the ones used for the original store. If they are different, you will not be allowed to create the cache.
In Advanced Options page, you can configure the following settings:
Eviction can't be enabled for this cache.
You can change the Clean Interval value. Default is 15 seconds.
This cache can be started automatically upon the completion of this process if you have checked the Start this cache on Finish checkbox on this dialog box.
You can make the cache to start automatically after service restart by checking the checkbox Auto start this cache on service startup.
Note
Eviction is not supported for a distributed cache with persistence.
Warning
The cache will not start on a node on which the persistence store is inaccessible.
- Click Finish to complete the process. Your created cache will appear in Clustered Caches page with the server nodes and their status and a success notification will be displayed in the notification panel.
Warning
If a database already exists with the specified Database Name, you will be prompted with an error message "Database already exists".
Using PowerShell
You can also use the PowerShell to manage persistence caches by using the NCache supported PowerShell cmdlets.
Create Cache
The New-Cache PowerShell cmdlet is responsible for creating new caches.
Important
NCache Persistence requires a shared path that is accessible from all nodes. Make sure that all nodes have read and write access to the shared path.
The following command creates a distributed cache with persistence named demoPersistenceCache on the server nodes 20.200.20.174 and 20.200.20.175. A new NCache Persistence store named demoPersistenceCache_db is created on the path \\fileserver\stores using the provided connection string. The topology is PartitionedOfReplica and cache size is 1024MB.
Note
For Windows, User Name and Password are required if authentication is enabled on the file share. You can also provide domain name along with user name as domain_name\user_name.
New-Cache -Name demoPersistenceCache -Server "20.200.20.174,20.200.20.175" -InMemoryStoreType DistributedCacheWithPersistence -NewPersistenceStore -PersistenceStoreConnectionString "\\fileserver\stores;domain_name\user_name;password" -Topology PartitionedOfReplica -Size 1024
Warning
The cache creation process will fail if the connection to the persistence store is unsuccessful.
Start Cache
Start-Cache cmdlet enables the user to start the registered cache. If the server nodes are specified, the Cache process is started on the specified nodes.
Warning
The cache will not start on the node on which the persistence store is inaccessible.
Perform this step on all server nodes to start the previously created demoPersistenceCache.
Start-Cache -Name demoPersistenceCache
See Also
Create New Distributed Cache with Persistence
Add Local Remote Clients
NCache Programmer's Guide
NCache PowerShell Guide