1

誰にもC#を使用してAWSのelasticache(memcached)クラスタに接続するサンプルコードがありますか?AmazonのAWS elasticache - c#の例

私はthis例を見つけましたが、少し古いようです(ライブラリは2010年以降です)。 This github libraryが動作する可能性があります。そこには多くの例はありません。

おかげで、

答えて

1

は、それがリチャードSeroterによってこのpluralsightビデオでの作業手に入れました。

ステップ:

は以下のnugetのパッケージを追加します。

をEnyimMemCachedそして、ウェブの設定でこの内部configSectionsノードを追加します。

<sectionGroup name="enyim.com"> 
     <section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching"/> 
    </sectionGroup> 

は、それからちょうど以下、これを追加します。 system.webノード(したがって、system.webの兄弟ノードです)。あなたのelasticacheエンドポイントでURLとポートを置き換えてください:

<enyim.com> 
    <memcached> 
     <servers> 
     <add address="...your elasticache url here...." port="your port here..."></add> 
     </servers> 
    </memcached> 
    </enyim.com> 

はその後、私のビューのアクションで私は、キャッシュ値を設定し、それを読み出すと呼ばれます。 。それは、それが公表されていますし、AWS上で稼働している場合にのみ機能します(ローカルで働いていませんでした):

public ActionResult Index() 
     { 
      var client = new MemcachedClient(); 

      string myCacheKey = "MyCacheKey"; 
      client.Store(Enyim.Caching.Memcached.StoreMode.Set, myCacheKey, "If you see this it worked."); // set the cache. 
      string myCachedString = client.Get<string>(myCacheKey); 

      ViewBag.MyCache = myCachedString ?? "**** SORRY, DIDN'T WORK..***.."; 
      return View(); 

     } 

ホップ、これは誰かに役立ちます。

関連する問題