Cache Configurations
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 Syntax and tags
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>.
-->
<configuration>
<cache-config cache-name="democache" config-id="44fb997a-f6a7-433b-9439-7ef9de9f47c7" config-version="0">
<cache-settings inproc="False">
<logging enable-logs="True" trace-errors="True" trace-debug="False" log-path=""/>
<performance-counters enable-counters="True" snmp-port="0"/>
<cache-notifications item-remove="False" item-add="False" item-update="False"/>
<cleanup interval="15sec"/>
<storage type="heap" cache-size="1024mb"/>
<eviction-policy default-priority="normal" eviction-ratio="5%"/>
<cache-topology topology="mirrored">
<cluster-settings operation-timeout="60sec" stats-repl-interval="60sec" use-heart-beat="False">
<cluster-connection-settings port-range="1" connection-retries="2" connection-retry-interval="2secs" cluster-port="7801"/>
</cluster-settings>
</cache-topology>
<client-death-detection enable="False" grace-interval="60sec"/>
</cache-settings>
<cache-deployment>
<servers>
<server-node ip="192.168.0.104"/>
</servers>
</cache-deployment>
</cache-config>
</configuration>
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
not.
config-id
: Auto-generated unique Id for modified configuration.
last-modified
: Contains information related to last modification in cache
configuration.
<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.
<performance-counters enable-counters="True"/>
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.
<replication-strategy synchronous="False"/>
This feature is only present in NCache Enterprise. 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"/>
Note
This feature is only available in NCache Enterprise.
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
to "False"
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"/>
The 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 interval="15sec"/>
The 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"/>
The 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
"False"
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
following:
- High
- Above-normal
- Normal
- Below-normal
- Low
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="mirrored">
<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. For OpenSource edition, only Mirror topology is available.
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"/>
The <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