本文整理汇总了C#中CouchbaseClient.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# CouchbaseClient.Remove方法的具体用法?C# CouchbaseClient.Remove怎么用?C# CouchbaseClient.Remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CouchbaseClient
的用法示例。
在下文中一共展示了CouchbaseClient.Remove方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_Store_StoreMode_Set
public void Test_Store_StoreMode_Set()
{
var client = new CouchbaseClient("memcached-config");
var result = client.Store(StoreMode.Set, Key, "value");
Assert.AreEqual(result, true);
client.Remove(Key);
}
示例2: Run
public override void Run()
{
var config = new CouchbaseClientConfiguration();
config.Urls.Add(new Uri("http://localhost:8091/pools/"));
config.Bucket = "default";
var client = new CouchbaseClient(config);
//add or replace a key
client.Store(StoreMode.Set, "key_1", 1);
Console.WriteLine(client.Get("key_1"));
var success = client.Store(StoreMode.Add, "key_1", 2);
Console.WriteLine(success); //will return false
success = client.Store(StoreMode.Replace, "key_1", 2);
Console.WriteLine(success); //will return true
success = client.Store(StoreMode.Replace, "key_2", 2);
Console.WriteLine(success); //will return false
//add a new key
client.Store(StoreMode.Set, "key_3", 1);
Console.WriteLine(client.Get("key_3"));
client.Remove("key_1");
client.Remove("key_2");
}
示例3: Run
public override void Run()
{
var config = new CouchbaseClientConfiguration();
config.Urls.Add(new Uri("http://localhost:8091/pools/"));
config.Bucket = "default";
var client = new CouchbaseClient(config);
//Store a key, but don't return success until it is written
//to disk on the master (or times out)
var success = client.ExecuteStore(StoreMode.Set, "key_1", 2, PersistTo.One);
Console.WriteLine(success.Success); //will return false
//Store a key, but don't return success until it is
//replicated to 2 nodes (or times out)
//will fail on a single or two node cluster
success = client.ExecuteStore(StoreMode.Set, "key_1", 2, ReplicateTo.Two);
Console.WriteLine(success.Success); //will return false
//Store a key, but don't return success until it is written
//to disk on the master and replicated to 2 nodes (or times out)
//will fail on a single or two node cluster
success = client.ExecuteStore(StoreMode.Set, "key_1", 2, PersistTo.One, ReplicateTo.Two);
Console.WriteLine(success.Success); //will return false
client.Remove("key_1");
client.Remove("key_2");
}
示例4: Run
public override void Run()
{
var config = new CouchbaseClientConfiguration();
config.Urls.Add(new Uri("http://localhost:8091/pools/"));
config.Bucket = "default";
var client = new CouchbaseClient(config);
var user1 = new User
{
Username = "cmathison",
Name = "Carrie Mathison",
Email = "[email protected]",
Password = "IHeartNick",
Logins = 0
};
var user2 = new User
{
Username = "nbrody",
Name = "Nicholas Brody",
Email = "[email protected]",
Password = "issa",
Logins = 0
};
//store the user - ExecuteStore returns detailed error info, if any
var result1 = client.ExecuteStore(StoreMode.Set, user1.Email, user1);
if (!result1.Success)
{
Console.WriteLine("Store failed with message {0} and status code {1}", result1.Message, result1.StatusCode);
if (result1.Exception != null)
{
throw result1.Exception;
}
}
var result2 = client.ExecuteStore(StoreMode.Set, user2.Email, user2);
//same check as result1 would be useful
var doc = client.Get<User>(user1.Email);
Console.WriteLine(doc.Name);
//get doc with extended info
var result = client.ExecuteGet<User>(user1.Email);
//update login count
doc.Logins += 1;
//update document (ignore errors for lab)
client.ExecuteStore(StoreMode.Replace, user1.Email, doc);
doc = client.Get<User>(user1.Email);
Console.WriteLine("User {0} had {1} logins", doc.Name, doc.Logins);
client.Remove(user1.Email);
client.Remove(user2.Email);
}
示例5: using
bool ICacheManager.Delete(string key)
{
bool bRet = false;
using (var client = new CouchbaseClient(config))
{
bRet = client.Remove(key);
}
return bRet;
}
示例6: Run
public override void Run()
{
var config = new CouchbaseClientConfiguration();
config.Urls.Add(new Uri("http://localhost:8091/pools/"));
config.Bucket = "default";
var client = new CouchbaseClient(config);
//Store JSON
client.StoreJson(StoreMode.Set, "CT_Hartford", new City { Name = "Hartford", State = "CT" });
//Get City instance back from JSON
var city = client.GetJson<City>("CT_Hartford");
Console.WriteLine(city.Name);
client.Remove("CT_Hartford");
}
示例7: Main
public static void Main()
{
var clientA = new CouchbaseClient("couchbase");
var clientB = new CouchbaseClient();
clientA.Remove("fooA");
IStoreOperationResult result = clientA.ExecuteStore(StoreMode.Set, "fooA", "barA");
var itemA = clientA.Get<string>("fooA");
Console.WriteLine(itemA);
clientB.ExecuteStore(StoreMode.Set, "fooB", "barB");
var itemB = clientB.Get<string>("fooB");
Console.WriteLine(itemB);
Console.ReadLine();
}
示例8: Run
public override void Run()
{
var config = new CouchbaseClientConfiguration();
config.Urls.Add(new Uri("http://localhost:8091/pools/"));
config.Bucket = "default";
var client = new CouchbaseClient(config);
Console.WriteLine("Set the counter to 0");
client.Increment("counter", 0, 0);
Console.WriteLine("Increment by 1, set initial value to 0");
client.Increment("counter", 0, 1);
Console.WriteLine(client.Get("counter"));
Console.WriteLine("Increment by 10, initial value is ignored since it exists");
client.Increment("counter", 0, 10);
Console.WriteLine(client.Get("counter"));
client.Remove("counter");
Console.WriteLine("Set the counter to 1000");
client.Decrement("counter", 1000, 0);
Console.WriteLine("Decrement by 1");
client.Decrement("counter", 0, 1);
Console.WriteLine(client.Get("counter"));
Console.WriteLine("Decrement by 10, initial value is ignored since it exists");
client.Decrement("counter", 0, 10);
Console.WriteLine(client.Get("counter"));
}
示例9: Test_Store_StoreMode_Add_Will_Fail_If_Key_Exists
public void Test_Store_StoreMode_Add_Will_Fail_If_Key_Exists()
{
var client = new CouchbaseClient("memcached-config");
var result = client.Store(StoreMode.Set, Key, "value");
var resultWhenKeyExists = client.Store(StoreMode.Add, Key, "value");
Assert.AreEqual(resultWhenKeyExists, false);
client.Remove(Key);
}