zoukankan      html  css  js  c++  java
  • 初涉AWS 之 ElasticCache——MemCached在.Net中的用法

    紧接上一篇,此篇介绍aws的ElasticCache中的MemCached的用法

    AWS的MemCached有一项特别的地方是可以主动发现节点,称为Auto Discovery。

    NuGet中下载Enyim.Caching,Amazon.ElastiCacheCluster。

    配置appconfig

     1 <configSections>
     2     <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
     3     <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
     4     <section name="clusterclient" type="Amazon.ElastiCacheCluster.ClusterConfigSettings, Amazon.ElastiCacheCluster" />
     5   <section name="membase" type="Membase.Configuration.MembaseClientSection, Membase" /></configSections>
     6   <clusterclient>
     7     <!-- the hostname and port values are from step 1 above -->
     8     <endpoint hostname="{ip地址}" port="6379" />
     9     <!--bigdata-redis.xdnqsx.0001.cnn1.cache.amazonaws.com.cn-->
    10   </clusterclient>
    appconfig

    类中引用命名空间

    1 using Enyim.Caching;
    2 using Enyim.Caching.Memcached;
    3 using Amazon.ElastiCacheCluster;
    class

    直接生成client

    1             ElastiCacheClusterConfig config = new ElastiCacheClusterConfig();
    2             MemcachedClient memClient = new MemcachedClient(config);
    3       
    client

    使用MemCached简单示例

    1 cache.Store(StoreMode.Set, key, value, ts);
    store

    以上代码尚未完成测试

  • 相关阅读:
    BZOJ 3505: [Cqoi2014]数三角形 数学
    BZOJ 3931: [CQOI2015]网络吞吐量 最大流
    BZOJ 4236: JOIOJI MAP
    BZOJ 4247 挂饰 背包DP
    hihocoder #1224 : 赛车 dfs
    hihocoder #1223 : 不等式 水题
    BZOJ 3224: Tyvj 1728 普通平衡树 treap
    uoj #31. 【UR #2】猪猪侠再战括号序列 贪心
    BZOJ 1005: [HNOI2008]明明的烦恼 Purfer序列 大数
    心跳回忆4 攻略
  • 原文地址:https://www.cnblogs.com/riusmary/p/8352523.html
Copyright © 2011-2022 走看看