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="partition-replica"> <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
- Partition Replica Topology
- Replicated Topology
- Partitioned Topology
- Mirror 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
<alerts> <email-notification email-notification-enabled="False" sender="" smtp-server="" smtp-port="0"ssl="False" authentication="False" sender-login="" sender-password=""/> <alerts-types cache-stop="False" cache-start="False" node-left="False" node-joined="False"state-transfer-started="False" state-transfer-stop="False" state-transfer-error="False"cache-size="False"/> </alerts>
This feature is only available in NCache Enterprise Edition.
If Event notifications through email is required, then information for its setup is configured here:
Email-notification: contains all the information related to the email
Email-notification-enabled: enables notification through email
Sender : specify the email account from whom the email notifications are
Smtp -server: specify the gateway to send email notifications
Smtp -port: The port number used to forward emails
SSL : (Secure Socket Layer) To enable SSL security
Authentication : If any authentication is required, this is to be True
Sender-login : if Authentication is required, specify the login name
Sender-password : Authentication password is entered here
Alert-Types: Specifies at which event an automated email is to be generated
Cache-stop : if the cache is stopped at any moment
Cache-start : at start of cache, email notification is generated
Node-left : when a server node leaves the cluster or if a server node is
inaccessible for any reason, email notification will be sent if this is enabled
Node-joined : At joining of any server node
State-Transfer-started : To notify whenever a state transfer is occurred
which happens when Load balancing is performed
Cache-size : whenever cache size is changed (Hot Applicable)
This XML tag specifies the queuing and service SQL notification architecture.
Use-default: The attribute can be set to True/False. If the attribute is set
to "True" then default SQL Dependency service and queue will be created at run
time. If the attribute is set to "False" then the custom define SQL Dependency
service and queue will be created and used by NCache.