• Products
  • Solutions
  • Customers
  • Resources
  • Company
  • Pricing
  • Download
Try Playground
  • Cache Management
  • New-Cache
Show / Hide Table of Contents
  • Command-Line Interface
  • Cmdlets in Different Editions
  • PowerShell on Windows
    • Setting Up PowerShell Environment
    • Install PowerShell without NCache Installation
  • Install-NCacheModule
  • Client Management
    • Add-ClientNode
    • Remove-ClientNode
    • Add-ClientNodeSecurity
  • Cache Management
    • New-Cache
    • Start-Cache
    • Stop-Cache
    • Set-CacheConfiguration
    • Export-CacheData
    • Export-CacheKeys
    • Export-CacheConfiguration
    • Get-CacheCount
    • Clear-Cache
    • Remove-Cache
    • Set-NCServiceConfigSetting
  • Client Cache
    • New-ClientCache
    • Add-ClientCacheRefDatatype
    • Remove-ClientCacheRefDatatype
    • Remove-ClientCache
  • Node Management
    • Add-Node
    • Remove-Node
  • Query Index
    • Add-QueryIndex
    • Remove-QueryIndex
  • Loader & Refresher
    • Add-LoaderDataSet
    • Invoke-RefresherDataset
    • Remove-LoaderDataSet
    • Add-StartupLoader
    • Remove-StartupLoader
  • DataSource Providers
    • Add-BackingSource
    • Remove-BackingSource
  • Custom Dependency
    • Add-CustomDependency
    • Remove-CustomDependency
  • Pub/Sub Messaging
    • Get-Topics
  • Bridge
    • New-Bridge
    • Add-BridgeNode
    • Add-BridgeCache
    • Start-Bridge
    • Set-BridgeCacheMode
    • Start-BridgeStateTransfer
    • Stop-Bridge
    • Remove-Bridge
    • Remove-BridgeCache
    • Remove-BridgeNode
  • Mapreduce
    • Add-MapReduce
  • Compact Serilaization
    • Add-CompactType
    • Add-PortableType
    • Remove-PortableType
    • Remove-CompactType
  • Security
    • Enable-NCacheSecurity
    • Add-NCacheUserOrGroup
    • Remove-NCacheUserOrGroup
    • Enable-NCacheTLS
    • Disable-NCacheTLS
    • Disable-NCacheSecurity
    • Enable-NCEncryption
    • Disable-NCEncryption
  • Data Persistence
    • Suspend-NCacheDataPersistence
    • Resume-NCacheDataPersistence
  • Monitoring
    • Get-Caches
    • Get-CacheLogs
    • Get-CacheLogsList
    • Get-ConnectedClients
    • Get-CacheClientStatistics
    • Get-CacheServerStatistics
    • Add-TestData
    • Test-Stress
    • Get-ClusterHealth
    • New-MemoryDump
    • Get-MemoryDumpList
    • Send-MemoryDump
    • Remove-MemoryDump
    • Measure-CachePerformance
    • Invoke-ServerLogger
    • Import-CacheData
  • Management Center
    • Start-NCacheManagementCenter
    • Stop-NCacheManagementCenter
    • Set-CacheServerPublicIP
  • NCache Playground
    • Start-NCachePlaygroundProcess
    • Stop-NCachePlaygroundProcess
  • NCache Registration
    • Register-NCache
    • Register-NCacheEvaluation
    • Unregister-NCache
    • Get-NCacheVersion

New-Cache - PowerShell Cmdlet

This PowerShell Cmdlet enables the user to create a new cache on one or more server nodes. A new cache can be created by user-specified configurations in a config file placed on the path provided by the user if the user doesn't want to use the default configurations.

You can create a cache with the following topologies using this PowerShell Cmdlet:

  • Local
  • Mirror
  • Replicated
  • Partitioned
  • PartitionReplica (NCache Enterprise only)

Moreover, you also have to specify the InMemoryStoreType for these topologies as part of this PowerShell Cmdlet. They are as follows:

  • DistributedCache
  • DistributedCacheWithPersistence (Only for Local, PartitionReplica, and Partitioned topologies)
  • PubSubMessaging
Note

This feature is only available in NCache Enterprise and Professional.

  • Windows PowerShell
  • Linux CLI
Note

It is recommended that you use JSON serialization if you are using ASP.NET 5.0 and above. For more details click here. Also, the DistributedCacheWithPersistence in-memory store type only support JSON serialization.

New-Cache [-Name] [-Server] [-CleanupInterval] [-ClusterPort] [-DefaultPriority] [-EvictionPolicy] [-EvictionRatio] [-Inproc] [-SerializationFormat] [-NoLogo ] [-Path] [-Port] [-ReplicationStrategy] [-Size] -Topology [-Credentials] [-InMemoryStoreType] [-UseExistingIndex] [-PersistenceStoreName] [-NewPersistenceStore] [-PersistenceStoreConnectionString]
Note

If you provide a path to your config.ncconf file through the Path parameter in your command, then InMemoryStoreType parameter can not be used. If it is used, you will be prompted with an error message.

Examples of New-Cache - PowerShell Cmdlet

  • This command creates a new cache named demoCache on server 20.200.20.11 with size 1024 MB and uses local topology since no topology is specified.
New-Cache -Name demoCache -Server 20.200.20.11 -Size 1024
  • This command creates a new cache named demoCache on server 20.200.20.11 having the size of 1024 MB, with the configuration that exists on the specified path.
New-Cache -Name demoCache -Server 20.200.20.11 –Path C:\config.xml
  • This command creates a new cache named demoCache on server 20.200.20.11, having size 1024 MB and topology set as Replicated and occupying the port number 8701.
New-Cache -Name demoCache -Server 20.200.20.11 -Size 1024 –Topology Replicated –ClusterPort 8701
  • This command creates a new cache named demoCache on server 20.200.20.11 having the size of 1024 MB, topology as Partitioned, eviction policy set as priority based and priority set as high as well as eviction ratio set as 10%. The cleanup interval of the cache will be 20 seconds.
New-Cache -Name demoCache -Server 20.200.20.11 -Size 1024 –Topology Partitioned –EvictionPolicy priority –DefaultPriority high –EvictionRatio 10 –CleanupInterval 20 -ClusterPort 8701
  • This command creates a new distributed cache named demoCache on servers 20.200.20.11 and 20.200.20.12 having size 1024 MB, topology replicated and occupying the port 8701 for simple case.
New-Cache -Name demoCache -Server "20.200.20.11,20.200.20.12" -Size 1024 -Topology Replicated -ClusterPort 8701
  • This command creates a new Distributed Cache named demoCache with store type of PubSubMessaging on server 20.200.20.11 having size 1024 MB with partitioned topology and occupying the port 8701 for simple case.
New-Cache -Name demoCache -Server "20.200.20.11" -Size 1024 -InMemoryStoreType PubSubMessaging -Topology Partitioned
  • This command creates a new Distributed cache with persistence named PersistenceCache of store type DistributedCacheWithPersistence on servers 20.200.20.11 and 20.200.20.12 having size 1024 MB with replication enabled. New persistence store named persistence_store is created at \\Fileserver\stores\store1 on all server nodes.
New-Cache -Name PersistenceCache -Server "20.200.20.11,20.200.20.12" -Size 1024 -InMemoryStoreType DistributedCacheWithPersistence -PersistenceStoreName "persistence_store" -NewPersistenceStore -PersistenceStoreConnectionString "\\Fileserver\stores\store1;domain_name\user_name;password" -Topology PartitionReplica

Properties

Note

The parameters with asterisk (*) on their names are the required parameters and the rest are optional.

Parameters Data Types Description Default Value
-Name* <String> Specifies the name of the new cache that is to be registered. -
-Server* <String> Specifies the NCache server names where Cache should be configured, separated by commas, e.g, 20.200.20.11, 20.200.20.12. Local Machine
-CleanupInterval <Integer> Specifies the time interval in seconds after which cache cleanup is called and all the expired items are cleared from the cache. 15 seconds
-ClusterPort <Integer> Specifies the port of the server, at which server listens. 8250
-DefaultPriority <String> If the eviction policy opted by the user is Priority based; this parameter specifies the default priority. Possible values are
  • High
  • Above Normal
  • Normal
  • Below Normal
  • Low
  • Normal
    -EvictionPolicy <String> Specifies the eviction policy for cache items. Cached items will be cleared from the cache according to the specified policy if the cache reaches its limit. Possible values are
  • Priority Based
  • LFU
  • LRU
    NOTE: LRU and LFU are only available in Enterprise edition.
  • LRU
    -EvictionRatio <Decimal> Specifies the eviction ratio (Percentage) for cache items. Cached items will be cleared from the cache according to the specified ratio if the cache reaches its limit. 5%
    -Inproc <SwitchParamter> Specifies the Isolation level for local cache. False
    -SerializationFormat <SwitchParamter> Specifies the serialization format of the objects stored in the cache. Possible values are
  • Binary
  • JSON
  • Binary for DistributedCache and PubSubMessaging cache. JSON for DistributedCacheWithPersistence cache.
    -NoLogo <SwitchParameter> Suppresses display of the logo banner. False
    -Path <String> Specifies the path of the configuration file if the user doesn’t want to use the default configurations. -
    -Port <Integer> Specifies the server port where NCache server is listening. 8250
    -ReplicationStrategy <String> If the topology chosen by the user is Partitioned Replica; this parameter specifies the replication strategy. The possible values are
  • Async
  • Sync
  • Async
    -Size <Long> Specifies the size of the Cache that is to be newly created. 1024 (For Local Cache)
    -Topology <String> For topology other than local you have to give topology and cluster port. Specifies the topology in case of clustered cache. Possible topologies are
  • Mirror
  • Replicated
  • Partitioned
  • PartitionReplica
    NOTE: PartitionReplica is only available in Enterprise edition.
  • Local
    Credentials <pscredential> Specifies the user credentials required to authorize access for the specified operation. These credentials should belong to a user with the appropriate permissions at the node. -
    -InMemoryStoreType <String> Specifies the purpose for which this cache will be used. The possible values are:
  • DistributedCache
  • DistributedCacheWithPersistence
  • PubSubMessaging
  • DistributedCache
    -UseExistingIndex <SwitchParameter> Specifies whether cache should use an existing index or create a new one. False
    -PersistenceStoreName <String> Specifies the persistence store name. This parameter is required if the store type for this cache is DistributedCacheWithPersistence. -
    -NewPersistenceStore <SwitchParameter> Specifies that a new store be created for this cache. True
    -PersistenceStoreConnectionString <String> Specifies a valid connection string for persistence store. This parameter is required if the store type for this cache is Distributed Cache With Persistence. -
    new-cache [-name] [-server] [-cleanupinterval] [-clusterport] [-defaultpriority] [-evictionpolicy] [-evictionratio] [-inproc] [-serializationformat] [-nologo ] [-path] [-port] [-replicationstrategy] [-size] -topology [-credentials] [-inmemorystoretype] [-useexistingindex] [-persistencestorename] [-newpersistencestore] [-persistencestoreconnectionstring]
    
    Note

    If you provide a path to your config.ncconf file through the path parameter in your command, then inmemorystoretype parameter can not be used. If it is used, you will be prompted with an error message.

    Examples of New-Cache

    • This command creates a new cache named demoCache on server 20.200.20.11 with size 1024 MB and uses local topology since no topology is specified.
    new-cache -name demoCache -server 20.200.20.11 -size 1024
    
    • This command creates a new cache named demoCache on server 20.200.20.11 having the size of 1024 MB, with the configuration that exists on the specified path.
    new-cache -name demoCache -server 20.200.20.11 –path /usr/config.xml
    
    • This command creates a new cache named demoCache on server 20.200.20.11 , having size 1024 MB and topology set as Replicated and occupying the port number 8701.
    new-cache -name demoCache -server 20.200.20.11 -size 1024 –topology Replicated –clusterport 8701
    
    • This command creates a new cache named demoCache on server 20.200.20.11 having the size of 1024 MB, topology as Partitioned, eviction policy set as priority based and priority set as high as well as eviction ratio set as 10%. The cleanup interval of the cache will be 20 seconds.
    new-cache -name demoCache -server 20.200.20.11 -size 1024 –topology Partitioned –evictionpolicy priority –defaultpriority high –evictionratio 10 –cleanupinterval 20 -clusterport 8701
    
    • This command creates a new distributed cache named demoCache on servers 20.200.20.11 and 20.200.20.12 having size 1024 MB, topology replicated and occupying the port 8701 for simple case.
    new-cache -name demoCache -server "20.200.20.11,20.200.20.12" -size 1024 -topology Replicated -clusterport 8701
    
    • This command creates a new Distributed Cache named demoCache with store type of PubSubMessaging on server 20.200.20.11 having size 1024 MB with partitioned topology and occupying the port 8701 for simple case.
    new-cache -name demoCache -server "20.200.20.11" -size 1024 -inmemorystoretype PubSubMessaging -topology Partitioned
    
    • This command creates a new Distributed cache with persistence named PersistenceCache of store type DistributedCacheWithPersistence on servers 20.200.20.11 and 20.200.20.12 having size 1024 MB with replication enabled. New persistence store named persistence_store is created at //Fileserver/stores/store1 on all server nodes.
    new-cache -name PersistenceCache -server "20.200.20.11,20.200.20.12" -size 1024 -inmemorystoretype DistributedCacheWithPersistence -persistencestorename "persistence_store" -newpersistencestore -PersistenceStoreConnectionString "//Fileserver/stores/store1;domain_name/user_name;password" -topology PartitionReplica
    

    Properties

    Note

    The parameters with asterisk (*) on their names are the required parameters and the rest are optional.

    Parameters Data Types Description Default Value
    -name* <String> Specifies the name of the new cache that is to be registered. -
    -server* <String> Specifies the NCache server names where Cache should be configured, separated by commas, e.g, 20.200.20.11, 20.200.20.12. Local Machine
    -cleanupinterval <Integer> Specifies the time interval in seconds after which cache cleanup is called and all the expired items are cleared from the cache. 15 seconds
    -clusterport <Integer> Specifies the port of the server, at which server listens. -
    -defaultpriority <String> If the eviction policy opted by the user is Priority based; this parameter specifies the default priority. Possible values are
  • High
  • Above Normal
  • Normal
  • Below Normal
  • Low
  • Normal
    -evictionpolicy <String> Specifies the eviction policy for cache items. Cached items will be cleared from the cache according to the specified policy if the cache reaches its limit. Possible values are
  • Priority Based
  • LFU
  • LRU
    NOTE: LRU and LFU are only available in Enterprise edition.
  • LRU
    -evictionratio <Decimal> Specifies the eviction ratio (Percentage) for cache items. Cached items will be cleared from the cache according to the specified ratio if the cache reaches its limit. 5%
    -inproc <SwitchParamter> Specifies the Isolation level for local cache. False
    -serializationformat <SwitchParamter> Specifies the serialization format of the objects stored in the cache. Possible values are
  • Binary
  • JSON
  • Binary for DistributedCache and PubSubMessaging cache. JSON for DistributedCacheWithPersistence cache.
    -nologo <SwitchParameter> Suppresses display of the logo banner. False
    -path <String> Specifies the path of the configuration file if the user doesn’t want to use the default configurations. -
    -port <Integer> Specifies the server port where NCache server is listening. 8250
    -replicationstrategy <String> If the topology chosen by the user is Partition Replica; this parameter specifies the replication strategy. The possible values are
  • Async
  • Sync
  • Async
    -size <Long> Specifies the size of the Cache that is to be newly created. 1024 (For Local Cache)
    -topology <String> For topology other than local you have to give topology and cluster port. Specifies the topology in case of clustered cache. Possible topologies are
  • Mirror
  • Replicated
  • Partitioned
  • PartitionReplica
    NOTE: PartitionReplica is only available in Enterprise edition.
  • Local
    -userid <String> Specifies the user id used to authorize the user for this operation. It is required in case security is enabled on Cache Server. This user id must be the active directory. -
    -password <String> Specifies the password of the user that is used to authorize the user for this operation. It is required in case security is enabled on Cache Server. This password must be the same as the active directory user password. -
    -inmemorystoretype <String> Specifies the purpose for which this cache will be used. The possible values are:
  • DistributedCache
  • DistributedCacheWithPersistence
  • PubSubMessaging
  • DistributedCache
    -useexistingindex <SwitchParameter> Specifies whether cache should use an existing index or create a new one. False
    -persistencestorename <String> Specifies the persistence store name. This parameter is required if the store type for this cache is DistributedCacheWithPersistence. -
    -newpersistencestore <SwitchParameter> Specifies that a new store be created for this cache. True
    -persistencestoreconnectionstring <String> Specifies a valid connection string for persistence store. This parameter is required if the store type for this cache is Distributed Cache With Persistence. -
    In This Article
    • Examples of New-Cache - PowerShell Cmdlet
    • Properties
    • Examples of New-Cache
    • Properties

    Contact Us

    PHONE

    +1 (214) 764-6933   (US)

    +44 20 7993 8327   (UK)

     
    EMAIL

    sales@alachisoft.com

    support@alachisoft.com

    NCache
    • NCache Enterprise
    • NCache Professional
    • Edition Comparison
    • NCache Architecture
    • Benchmarks
    Download
    Pricing
    Try Playground

    Deployments
    • Cloud (SaaS & Software)
    • On-Premises
    • Kubernetes
    • Docker
    Technical Use Cases
    • ASP.NET Sessions
    • ASP.NET Core Sessions
    • Pub/Sub Messaging
    • Real-Time ASP.NET SignalR
    • Internet of Things (IoT)
    • NoSQL Database
    • Stream Processing
    • Microservices
    Resources
    • Magazine Articles
    • Third-Party Articles
    • Articles
    • Videos
    • Whitepapers
    • Shows
    • Talks
    • Blogs
    • Docs
    Customer Case Studies
    • Testimonials
    • Customers
    Support
    • Schedule a Demo
    • Forum (Google Groups)
    • Tips
    Company
    • Leadership
    • Partners
    • News
    • Events
    • Careers
    Contact Us

    • EnglishChinese (Simplified)FrenchGermanItalianJapaneseKoreanPortugueseSpanish

    • Contact Us
    •  
    • Sitemap
    •  
    • Terms of Use
    •  
    • Privacy Policy
    © Copyright Alachisoft 2002 - 2025. All rights reserved. NCache is a registered trademark of Diyatech Corp.
    Back to top