初涉AWS 之 ElasticCache——MemCached在.Net中的用法

緊接上一篇,此篇介紹aws的ElasticCache中的MemCached的用法redis

AWS的MemCached有一項特別的地方是能夠主動發現節點,稱爲Auto Discovery。app

NuGet中下載Enyim.Caching,Amazon.ElastiCacheCluster。ide

配置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

類中引用命名空間ui

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

直接生成clientspa

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

使用MemCached簡單示例3d

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

以上代碼還沒有完成測試code

相關文章
相關標籤/搜索