本文整理汇总了C#中MemcachedClient.GetWithCas方法的典型用法代码示例。如果您正苦于以下问题:C# MemcachedClient.GetWithCas方法的具体用法?C# MemcachedClient.GetWithCas怎么用?C# MemcachedClient.GetWithCas使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemcachedClient
的用法示例。
在下文中一共展示了MemcachedClient.GetWithCas方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Cas_Study
public void Cas_Study()
{
using (var client = new MemcachedClient())
{
/*
* 非常重要的CAS操作
*/
client.Store(StoreMode.Set, "userid", "123456");
var result1 = client.GetWithCas("userid");
var result2 = client.Cas(StoreMode.Set, "userid", "6543321");
Assert.True(result2.Result);
var result3 = client.Cas(StoreMode.Set, "userid", "123456", result1.Cas);
Assert.False(result3.Result);
client.FlushAll();
}
}
示例2: GetFromMCWithCas
private ErrorTypes GetFromMCWithCas(string sKey, out TaskResultData oTast, out ulong cas)
{
ErrorTypes oError = ErrorTypes.NoError;
oTast = null;
cas = 0;
try
{
using (MemcachedClient oMc = new MemcachedClient(m_oMcConfig))
{
CasResult<string> oGetData = oMc.GetWithCas<string>(sKey);
if (oGetData.Result != null)
{
cas = oGetData.Cas;
XmlSerializer oXmlSerializer = new XmlSerializer(typeof(TaskResultData));
using (StringReader oStringReader = new StringReader(oGetData.Result))
{
oTast = (TaskResultData)oXmlSerializer.Deserialize(oStringReader);
}
}
}
}
catch
{
oError = ErrorTypes.TaskResult;
}
return oError;
}
示例3: Gets_Study
public void Gets_Study()
{
using (var client = new MemcachedClient())
{
/*
* 非常重要的CAS操作
*/
client.Store(StoreMode.Set, "userid", "123456");
var result = client.GetWithCas("userid");
Assert.AreEqual("123456", result.Result);
Assert.Greater(result.Cas, 0u);
client.FlushAll();
}
}