Over the years, developers and engineers have significantly advanced by creating amazing products and improving their features, but occasionally, crucial data loss issues confront developers. To achieve the best performance and scalability, they have started to use an in-memory distributed caching system.
Cache being a temporary store provides no data reliability. In distributed caching, data centers are spread out over several areas and because of natural disasters, this data may be destroyed. In these circumstances, there ought to be a means to protect data and avoid data loss.
Developers can choose from many popular distributed caching options available in the market such as NCache. NCache is an extremely fast and linearly scalable in-memory distributed cache. NCache enables developers to gear up their businesses and move to a new world of in-memory data distributed caching as it provides high data availability.
NCache Details Download NCache NCache Customers
Cache Backup and Restore: The Need
Unexpected things can happen at any time. Consider a developer who manages an online store. That website is used by many people, to purchase a variety of goods. After choosing a few items and adding them to your cart, the website unexpectedly crashes. Additionally, the developer’s data that was kept for every user was recently deleted. What steps now should the developer take? Since he lacks a backup, he is unable to roll anything back.
There arises a need for data backup and restoration. To make data highly available under all circumstances, and prevent data loss, NCache allows data backups and enables the developer to restore the cached data anytime.
NCache details NCache Tips Getting Started
Saving Data with NCache Backup
Users of NCache now have the option to make a backup of their cached data. This will enable users to create a copy of data so that it won’t be harmed in the event of a catastrophe or human error.
While the data is already in the cache, NCache creates a backup of the user-provided cached data at a different given file path. Because of this, the user should not be concerned about data loss and may continue to execute activities.

Figure 1: Data Backup and Restore in NCache
Restoring Data in NCache
Let’s examine the case of recovering that copy of the data from its designated location after the discussion about backing up your data with NCache.
In addition to offering data backup services to its users, NCache also enables them to securely restore their desired cached data back to the cache cluster from its saved location. This broadens the user’s perspective and makes them consider that their backup cached data is always available for recovery, regardless of the situation.
NCache details NCache Tips Getting Started
How to Backup Cache Data to a Specified Path?
NCache uses the PowerShell cmdlet to provide the user with the facility to back up data. During this, the user can cache the contents (data) of the cache to any specified path along with a path of dependent assemblies.
The PowerShell cmdlet used for this purpose is Export -CacheData as seen below:
1 |
Export -CacheData [-Name] [-Logo] [-Password] [-Path] [-Port] [-UserId] |
Example: The following command backs up all the cached items to a specified path:
1 |
Export -CacheData -Name myPartitionedCache -Path C:\recovery-path |
Example: The user can also specify the maximum file size along with other attributes, but the default file size is 5 MB. An example has been given below:
1 |
Export -CacheData -Name myPartitionedCache -Path C:\recovery-path -FileSize 2 |
Some of the important parameters for the cmdlet are explained below:
- Name: Specifies the name of the cache which is to be backed up or restored.
- Path: Specifies the path where the backup data is currently present.
- UserId: Specifies the User Id used to authorize a user if security is enabled on the cache server.
- Password: Specifies the password against the User Id.
NCache details NCache Tips Export Cache Data
How to Restore Data to Cache from a Specified Path?
To provide the user with the ability to restore data to the cache including all the dependent assembly files, NCache uses the PowerShell cmdlet Import -CacheData. This allows the user to import the cached data that resides on a specific path back to the cache.
The PowerShell cmdlet used for this purpose is:
1 |
Import -CacheData [-Name] [-Bulk Size] [-ErrorThreshold] [-Expiry] [-NoLogo] [-Password] [-Path] [-UserId] |
Example: The following command recovers the data from the specified file path to the cache:
1 |
Import -CacheData -Name myPartitionedCache -Path C:\backup-path |
Example: The following command recovers the data from the specified path to the cache including the dependent assembly files and a tolerance of a maximum of 10 errors:
1 |
Import -CacheData -Name myPartitionedCache -Path C:\backup-path -ErrorThreshold 10 |
Example: The following command recovers the data from the specified path to the cache including the dependent assembly files in a bulk of 100 along with the display of the logo banner to be suppressed.
1 |
Import -CacheData -Name myPartitionedCache -Path C:\backup-path -BulkSize 100 -NoLogo |
Some important cmdlet parameters are explained below:
- Name: Specifies the name of the cache which is to be backed up or restored.
- Path: Specifies the path where the backup data is currently present.
- ErrorThreshold: Specifies the number of errors that can be tolerated during recovering files from backup.
- Expiry: Sets the expiration policy of the data
NCache details NCache Tips Import Cache Data
Conclusion
NCache is an Open Source in-memory distributed cache for longer-term storage and recovery of data. To save important data and prevent data loss in the event of system failure, data backup is very vital. So, to get the best of data safety, use the NCache backup and restore feature. Download a fully working 60-day trial of NCache Enterprise and try it out for yourself.