1
有沒有人有使用C#連接到AWS彈性緩存(memcached)集羣的示例代碼?亞馬遜的AWS彈性 - c#示例
我發現this的例子,但它似乎有點老(圖書館是從2010年)。 This github library可能工作。那裏沒有太多的例子。
感謝,
有沒有人有使用C#連接到AWS彈性緩存(memcached)集羣的示例代碼?亞馬遜的AWS彈性 - c#示例
我發現this的例子,但它似乎有點老(圖書館是從2010年)。 This github library可能工作。那裏沒有太多的例子。
感謝,
明白了這個pluralsight視頻由理查德Seroter工作。
步驟:
添加以下NuGet包:EnyimMemCached
然後在你的web配置添加此內的configSections節點:
<sectionGroup name="enyim.com">
<section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching"/>
</sectionGroup>
然後添加下面這只是 system.web節點(所以它是system.web的兄弟節點)。一定要與你的elasticache端點更換網址和端口:
<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();
}
跳這有助於某人。