• 微软分布式缓存AppFabric(Velocity)-开发篇(一)开发环境准备


    配置好缓存群集时,在windows services 中启动名为:Microsoft project code named “Velocity”的服务,该服务默认不会自动启动

    1. 将Volocity的程序集copy到开发机器上。程序集位于Velocity的安装目录。程序集如下:

    CacheBaseLibrary.dll,

    ClientLibrary.dll,

     FabricCommon.dll,

     CASBase.dll.

    2.在VS的工程中添加以上程序集的引用

    3.配置缓存客户端的xml配置文件一般为.config文件,或直接在代码里指定配置

    选择用Routing Cleing或Simple Client,选择Routing Client会获得最佳的性能。

    Demo:

    下面是一个Routing Client的配置示例。示例中未启用本地缓存,但使用了两个缓存主机:CacheServer1和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 notifications 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>

    下面代码演示如何在代码中指定配置

    //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
    DataCacheFactory mycacheFactory 
        = new DataCacheFactory(servers, true, false);
    
    //get cache client for cache "NamedCache1"
    DataCache myDefaultCache = mycacheFactory.GetCache("NamedCache1");
  • 相关阅读:
    vim lua对齐indent无效
    C中的私有成员
    Lua 设置table为只读属性
    c语言结构体可以直接赋值
    Lua5.3 注册表 _G _ENV
    火狐浏览器调试ajax异步页面时报错NS_ERROR_UNEXPECTER
    ajax向后台请求数据,后台接收到数据并进行了处理,但前台就是调用error方法
    maven安装之后,或者升级之后遇到的问题:could not find or load main class org.codehaus.plexus.class.....
    jenkins执行shell命令,有时会提示“Command not found”
    shell 脚本替换文件中某个字符串
  • 原文地址:https://www.cnblogs.com/xuf22/p/2143788.html
Copyright © 2020-2023  润新知