Cache configuration file contains information regarding all registered caches/clusters. It is installed with NCache and is located at %NCHOME%/config. Modules that need to read the configurations first try to find config.ncconf in application folder i.e. alongside Web.config. If config.ncconf is not found in application folder, it then reads the configuration from installation folder.
config.ncconf file is explained below:
<!-- Configuration file (config.ncconf) contains the details of all the registered caches. All caches configurations are enclosed in <configuration></configuration> tag. Whereas each cache detail is enclosed in <cache-config></cache-config>. --> <cache-config config-id="0"> <cache-settings cache-name="demoCache" inproc="False" last-modified=""> ... </cache-settings> </cache-config>
cache-name: Is the cache identifier. Cache will be known by whatever name you will
specify here. This is the same name as you specify while initializing cache.
inproc: Determine whether the cache will run as InProc (in your application
process) or OutProc (in NCache Service process). If set to "False" cache will
run as OutProc or if set to "True" then cache will run as InProc.
config-version: Is used to determine whether the configuration is modified or
config-id: Auto-generated unique Id for modified configuration.
last-modified: Contains information related to last modification in cache
<logging enable-logs="True" trace-errors="True" trace-debug="False" log-path=""/>
NCache maintains a log file to write traces for information and debugging purposes. Using these tags user can enable or disable the various traces. By default, only “Error" trace is enabled, rest of the traces are disabled. Error trace does not affect the cache performance but for other traces we recommend not to enable them in a production environment as they affect the performance of NCache.
log-path: By default, log files for each cache are created at "%NCHOME%/log-files". However, you can specify a custom path if you want to save the logs elsewhere.
If this attribute is set to "True" NCache will update the published PerfMon counters. If set to "False", NCache will not update any of the published PerfMon counter.
This feature is only present in NCache Enterprise Edition. In case of Partition of Replica, you will find this tag in cache configuration. Replication strategy defines how data is replicated to backup node.
synchronous: This attribute can be set to True/False. If set to "False" then
data operation will be replicated asynchronously on the backup node. If set to
"True" then data operation will be replicated synchronously on the backup node.
<compression enable-compression="False" threshold="100kb"/>
This feature is only available in NCache Enterprise Edition.
This XML tag specifies whether the items greater than specified threshold should be compressed/decompressed at client side.
enable-compression: To enable compression set this attribute to "True" otherwise set it
threshold: Items greater than the value specified in threshold attribute will
only be compressed/decompressed at client side if compression is enabled.
As per above mentioned compression tag example only item greater than 100kb of size will be compressed/decompressed at client side.
<cache-notifications item-remove="False" item-add="False" item-update="False"/>
notifications XML tag specifies the registered event with Cache.
Item-add: This attribute can be set to "True" or "False". If set to "True"
will notify when an item is added to the cache and similarly if set to "False"
no notification will be fired if item is added in cache.
Item-remove: This attribute can be set to "True" or "False". If set to
"True" will notify when an item is removed from the cache and similarly if set
to "False" no notification will be fired if item is removed in cache.
Item-update: This attribute can be set to "True" or "False". If set to
"True" will notify when an item is updated in the cache and similarly if set to
"False" no notification will be fired if item is updated in cache.
cleanup XML tag specify the periodic interval after which item for
expiration will be checked:
Interval: If set to
"15sec" this means the expiration check will be performed after every 15sec.
<storage type="heap" cache-size="1024mb"/>
storage XML tag specifies the storage related details for cache:
Type: this attribute can only be set to "heap" as currently NCache only
supports heap based storage.
Cache-size: this attribute specifies the upper limit of cache size in MB.
<eviction-policy enabled="True" default-priority="normal" policy="priority" eviction-ratio="5%"/>
This XML tag specifies whether to perform the eviction or not. If eviction is enabled then cache will remove the existing item to accommodate new ones. Exiting items will be removed based on eviction strategy.
Enabled: To enable eviction set this attribute to "True" otherwise set it to
Policy: attribute the eviction policy to be used. Eviction policy can be one
of the following:
- LRU (Least recently used)
- LFU (Least frequently used)
- Priority based
Default-priority: specifies default priority that is associated with an item
if no priority is specified for that item. This attribute can be set to
This is only applicable in case of priority based eviction.
Eviction-ratio: specifies how much percentage of data should be evicted when
eviction is performed.
<expiration-policy enabled="True"> <absolute-expiration longer-enabled="False" longer-value="0" default-enabled="False" default-value="0"/> <sliding-expiration longer-enabled="False" longer-value="0" default-enabled="False" default-value="0"/> </expiration-policy>
enabled: enables the expiration policy.
longer-enabled: specifies whether Longer expiration is enabled. If true, the value should be provided.
longer-value: if longer-enabled is true, this value will be used for expiration.
default-enabled: specifies whether Default expiration is enabled. If true, the value should be provided as well.
default-value: If default-enabled is true, this value will be used for expiration.
<cache-topology topology="partitioned"> <cluster-settings operation-timeout="60sec" stats-repl-interval="2sec" use-heart-beat="True"> ... </cluster-settings> </cache-topology>
This XML tag is used for specifying the in-cluster communication details, it also contains a sub tag, channel, which further defines the communication details of the cluster:
Please Note, this tag will not be present in Local Cache.
topology: Specifies which topology does the cluster follow, it can be either
one of the following as provided by NCache
- Replicated Topology
- Partitioned Topology
operation-timeout: Determines the timeout of a connection
among the servers if a server in the cluster fails to respond
stats-repl-interval: (Statistics Replication Interval) the interval provided
to the cluster at which to synchronize their information among its servers
use-heart-beat: Heart Beat is used to monitor the connectivity between nodes.
<cluster-connection-settings cluster-port="7806" port-range="1" connection-retries="2" connection-retry-interval="2secs" join_retry_count="24" join_retry_timeout="5"/>
<cluster-connection-settings> XML tag specifies the details of port connectivity and other
communication options among the cluster servers:
cluster-port: connection is channeled through a TCP port; this value defines the
port which it occupies
port-range: when initializing, if the port provided is taken by some other
application then it will try to establish its connection on port incremented by
1, for this the range is provided i.e. to what range should it search for an
available TCP port
connection-retries: if connection among the node(s) is failed, then this
defines how many retries should be made to consider it a permanent failure.
connection-retry-interval: the interval between connection retries is
defined in this value