Microsoft Distributed cache appfabric (velocity)-Development Article (1) Development Environment preparation

Source: Internet
Author: User

When the cache cluster is configured, start the service named Microsoft Project code named "velocity" in Windows Services. This service will not be automatically started by default.

1. Set the volocityProgramCopy the set to the development machine. The Assembly is located in the velocity installation directory. The Assembly is as follows:

Cachebaselibrary. dll,

Clientlibrary. dll,

 Fabriccommon. dll,

 Casbase. dll.

2. Add the reference of the above assembly to the vs Project

3. Configure the xml configuration file of the cache client as the. config file, or directlyCodeSpecified configuration in

Select routing cleing or simple client, and select routing client to achieve the best performance.

 

Demo:

The following is a configuration example of a routing client. In this example, the local cache is not enabled, but two cache hosts are used: cacheserver1 and cacheserver2.

 <? XML version = "1.0" encoding = "UTF-8" ?> <  Configuration  >      <! -- 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  >      <! -- Routing client -->    <  Datacacheclient   Deployment ="Routing"  >      <! -- (Optional) specify local cache <localcache isenabled = "true" Sync = "ttlbased" objectcount = "100000" ttlvalue = "300"/> -->      <! -- (Optional) specify cache restrictions poll interval <clientnotification pollinterval = "300"/> -->          <! -- Cache host (s) -->          <  Hosts  >        <  Host           Name ="Cacheserver1"           Cacheport = "22233"           Cachehostname = "Distributedcacheservice"  />        <  Host           Name = "Cacheserver2"           Cacheport = "22233"           Cachehostname ="Distributedcacheservice"  />      </  Hosts  >    </  Datacacheclient  >  </  Configuration  > 

 

 

The following code demonstrates how to specify the configuration in the code.

 // Declare array for cache host (s) Datacacheserverendpoint [] servers =New Datacacheserverendpoint [1]; // Specify cache host (s) Servers [0] = New Datacacheserverendpoint (" Cacheserver2 ", 22233 ," Distributedcacheservice "); // Specify cache client Configuration Datachefactory mycachefactory = New Datacachefactory (servers, True , False );// Get cache client for cache "namedcache1" Datacache mydefaultcache = mycachefactory. getcache (" Namedcache1 ");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.