Application Configuration Settings (Velocity)
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]
With Microsoft project code named "Velocity," you may configure your application's cache client settings programmatically, by using an application configuration file, or by using both approaches at different places in your application. For more information about each of these configuration methods and how to select each, see Client Configuration Options (Velocity).
Regardless of the approach you take, you are configuring the same cache client setting. The tables in this document present the settings available to the cache client and show how they are configured in the XML-based application configuration file and programmatically, using code.
For more information about how to use these settings in your application, see the examples covered in Configuring the Cache Client with XML (Velocity).
Security Considerations
Cache clients should be used only by applications residing on application servers in your datacenter, within the perimeter of the corporate firewall. Communications between cache servers and cache hosts is not encrypted and is vulnerable to malicious network "sniffing" and "replay" attacks.
We highly recommend that you secure the XML-based application configuration files used to specify the cache client. Data in the cache is not encrypted and is available to any cache client with the appropriate configuration settings.
Cache Client Setting
The cache client type setting determines whether the cache client is routing or simple. For more information about these types, see Cache Clients and Local Cache (Velocity).
Setting | XML Configuration Location | Code Configuration Location |
---|---|---|
Client type |
The |
The |
Client timeout |
The |
The Timeout property of the DataCacheFactory class. |
Note
For best performance, we recommend that you use a routing client whenever possible. Only use a simple client when the computer that is running the cache client application does not have network connectivity to all cache hosts in the cluster.
Local Cache Settings
The local cache settings specify whether local cache should be enabled, the way locally cached objects should be invalidated, the object time-out, and whether cache notifications should be used to invalidate locally cached objects.
In the application configuration file, local cache settings are defined in the localCache
element, a child of the dataCacheClient
element. Programmatically, local cache is configured by using parameters of the DataCacheFactory class constructor. For more information about local cache, see Cache Clients and Local Cache (Velocity).
Setting | XML Configuration Location | Code Configuration Location |
---|---|---|
Local cache enabled |
The |
The |
Local cache invalidation method |
The |
The |
Local cache time-out (seconds) |
The |
The |
Specific cache notifications poll interval (seconds) |
(optional) Specified by the |
The |
Maximum locally-cached object count |
(optional) Specified by the object |
This setting is not able to be configured programmatically. The default value of 100,000 objects will be used for programmatic client configuration. |
Note
For best performance, only enable local cache for objects that change infrequently. Using local cache for frequently changing data may increase the chance that the client will be working with stale objects. Although you could lower the ttlValue
and make a process refresh the local cache more frequently, the increased load on the cluster may outweigh the benefits of having the local cache. In such cases of frequently changing data, it is best to disable local cache and pull data directly from the cluster.
Cache Host Settings
For each cache client, you must specify one or more cache hosts in the cluster. Specify lead hosts because cache hosts designated as lead hosts help manage the cluster. Initially, lead hosts are the first cache hosts installed in the cluster. For more information about lead hosts, see the Physical Model section of General Concept Models (Velocity).
In the application configuration file, the settings for each cache host are specified in a host
element, a child of the hosts
element. Programmatically, each host is defined in the class constructor of the DataCacheServerEndPoint class. Once instantiated, those DataCacheServerEndPoint objects are then passed to the DataCacheFactory class constructor as a single parameter.
Note
Routing clients use their internal routing table for tracking which cache hosts are in the cluster. These tables are maintained by the lead hosts in the cluster. Routing clients are not limited to the hosts specified in the application configuration settings for passing data. The hosts specified in the routing client's application configuration settings provide connectivity to a lead host in the cluster so that its routing table can be synchronized.
Setting | XML Configuration Location | Code Configuration Location |
---|---|---|
Cache server name |
The |
The |
Cache port number |
The |
The |
Cache host name (name of the cache host service on the cache server) |
The |
The |
Log Sink Settings
Log sinks are used to trace "Velocity" events, such as errors, warnings, and other informational messages. By default, each cache client automatically creates a console-based log sink with the event trace level set to Error
. If you want to override this default log sink, you can explicitly define other log sinks, such as a different console-based log sink, an Event Tracing for Windows (ETW), or a file-based log sink. Log sink settings may be configured in the application configuration file or programmatically; programmatic settings will always take precedence. For more information, see Log Sink Settings (Velocity).
XML-Only Application Configuration Settings
In order for the "Velocity" assemblies to read the XML elements in the application configuration file, you must include the configSections
element as the first element in the file under the configuration
tag. Within the configSections
element, you must include two section
elements so that the application can read the dataCacheClient
and fabric
elements.
The dataCacheClient
section
element tells the "Velocity" assemblies how to read the cache client configuration settings. The fabric
section
element tells the "Velocity" assemblies how to read the log sink settings in case they are added later to configure log sinks. It is a good practice to include both dataCacheClient
and fabric
section
elements, even if you do not start with any log sinks enabled.
The following code example shows what section
elements for the dataCacheClient
and fabric
elements look like.
<!--configSections must be the FIRST element -->
<configSections>
<!-- required to read the <dataCacheClient> element -->
<section name="dataCacheClient"
type="Microsoft.Data.Caching.DataCacheClientSection,
CacheBaseLibrary"
allowLocation="true"
allowDefinition="Everywhere"/>
<!-- required to read the <fabric> element, when present -->
<section name="fabric"
type="System.Data.Fabric.Common.ConfigFile,
FabricCommon"
allowLocation="true"
allowDefinition="Everywhere"/>
</configSections>
See Also
Concepts
Client Configuration Options (Velocity)
Cluster Configuration Settings (Velocity)
Log Sink Settings (Velocity)
Troubleshooting (Velocity)
Cache Administration with PowerShell (Velocity)
Other Resources
Installation and Deployment (Velocity)
Configuring the Cache Client with XML (Velocity)
Cache Concepts (Velocity)
Programming Guide (Velocity)