本文整理汇总了C#中CouchbaseClient.ExecuteGet方法的典型用法代码示例。如果您正苦于以下问题:C# CouchbaseClient.ExecuteGet方法的具体用法?C# CouchbaseClient.ExecuteGet怎么用?C# CouchbaseClient.ExecuteGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CouchbaseClient
的用法示例。
在下文中一共展示了CouchbaseClient.ExecuteGet方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParallerInsert
static void ParallerInsert(CouchbaseClient client, int n)
{
var options = new ParallelOptions { MaxDegreeOfParallelism = 4 };
Parallel.For(0, n, options, i =>
{
var key = "key" + i;
var value = "value" + i;
var result = client.ExecuteStore(StoreMode.Set, key, value);
if (result.Success)
{
Console.WriteLine("Write Key: {0} - Value: {1}", key, value);
var result2 = client.ExecuteGet<string>(key);
if (result2.Success)
{
Console.WriteLine("Read Key: {0} - Value: {1}", key, result2.Value);
}
else
{
Console.WriteLine("Read Error: {0} - {1}", key, result.Message);
}
}
else
{
Console.WriteLine("Write Error: {0} - {1}", key, result.Message);
}
});
}
示例2: SynchronousInsert
static void SynchronousInsert(CouchbaseClient client, int n)
{
for (int i = 0; i < n; i++)
{
var key = "key" + i;
var value = "value" + i;
var result = client.ExecuteStore(StoreMode.Set, key, value);
if (result.Success)
{
Console.WriteLine("Write Key: {0} - Value: {1}", key, value);
var result2 = client.ExecuteGet<string>(key);
if (result2.Success)
{
Console.WriteLine("Read Key: {0} - Value: {1}", key, result2.Value);
}
else
{
Console.WriteLine("Read Error: {0} - {1}", key, result.Message);
}
}
else
{
Console.WriteLine("Write Error: {0} - {1}", key, result.Message);
}
}
}
示例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);
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);
}
示例4: Client_Operations_Succeed_When_Bootstrapping_To_Pools_Root_Uri
public void Client_Operations_Succeed_When_Bootstrapping_To_Pools_Root_Uri()
{
var config = ConfigSectionUtils.GetConfigSection<CouchbaseClientSection>("pools-config");
var client = new CouchbaseClient(config);
string key = GetUniqueKey(), value = GetRandomString();
var storeResult = client.ExecuteStore(StoreMode.Add, key, value);
StoreAssertPass(storeResult);
var getResult = client.ExecuteGet(key);
GetAssertPass(getResult, value);
}
示例5: When_Getting_A_Key_From_A_Down_Node_No_Exception_Is_Thrown_And_Success_Is_False
public void When_Getting_A_Key_From_A_Down_Node_No_Exception_Is_Thrown_And_Success_Is_False()
{
var config = new CouchbaseClientConfiguration();
config.Urls.Add(new Uri("http://doesnotexist:8091/pools/"));
config.Bucket = "default";
var client = new CouchbaseClient(config);
var getResult = client.ExecuteGet("foo");
Assert.That(getResult.Success, Is.False);
Assert.That(getResult.Message, Is.StringContaining(ClientErrors.FAILURE_NODE_NOT_FOUND));
}
示例6: Client_Operations_Succeed_When_Heartbeat_Is_Not_Configured
public void Client_Operations_Succeed_When_Heartbeat_Is_Not_Configured()
{
var config = ConfigSectionUtils.GetConfigSection<CouchbaseClientSection>("min-config");
var client = new CouchbaseClient(config);
string key = GetUniqueKey(), value = GetRandomString();
var storeResult = client.ExecuteStore(StoreMode.Add, key, value);
StoreAssertPass(storeResult);
var getResult = client.ExecuteGet(key);
GetAssertPass(getResult, value);
}
示例7: Client_Operations_Succeed_When_Bootstrapping_To_Pools_Default_Root_Uri
public void Client_Operations_Succeed_When_Bootstrapping_To_Pools_Default_Root_Uri()
{
var config = ConfigSectionUtils.GetConfigSection<CouchbaseClientSection>("pools-default-config");
var client = new CouchbaseClient(config);
string key = GetUniqueKey(), value = GetRandomString();
var storeResult = client.ExecuteStore(StoreMode.Add, key, value);
Assert.That(storeResult.Success, Is.True, "Success was false");
Assert.That(storeResult.Message, Is.Null.Or.Empty, "Message was not empty");
var getResult = client.ExecuteGet(key);
GetAssertPass(getResult, value);
}
示例8: Client_Operations_Succeed_When_Heartbeat_Is_Disabled
public void Client_Operations_Succeed_When_Heartbeat_Is_Disabled()
{
var config = ConfigSectionUtils.GetConfigSection<CouchbaseClientSection>("heartbeat-config-off");
using (var client = new CouchbaseClient(config))
{
string key = TestUtils.GetUniqueKey(), value = TestUtils.GetRandomString();
var storeResult = client.ExecuteStore(StoreMode.Add, key, value);
TestUtils.StoreAssertPass(storeResult);
var getResult = client.ExecuteGet(key);
TestUtils.GetAssertPass(getResult, value);
}
}
示例9: Client_Operations_Succeed_When_Bootstrapping_To_Pools_Root_Uri
public void Client_Operations_Succeed_When_Bootstrapping_To_Pools_Root_Uri()
{
var config = new CouchbaseClientConfiguration();
config.Urls.Add(new Uri("http://localhost:8091/pools"));
config.Bucket = "default";
var client = new CouchbaseClient(config);
string key = GetUniqueKey(), value = GetRandomString();
var storeResult = client.ExecuteStore(StoreMode.Add, key, value);
StoreAssertPass(storeResult);
var getResult = client.ExecuteGet(key);
GetAssertPass(getResult, value);
}
示例10: When_ExecuteGet_Is_Called_With_Invalid_Configuration_Errors_Are_Returned
public void When_ExecuteGet_Is_Called_With_Invalid_Configuration_Errors_Are_Returned()
{
using (var client = new CouchbaseClient("bad-config"))
{
var keys = new[] { "exist1", "exist2" };
var results = client.ExecuteGet(keys);
Assert.AreEqual(keys.Count(), results.Count);
foreach (var result in results)
{
Assert.IsFalse(result.Value.HasValue);
Assert.IsFalse(result.Value.Success);
Assert.AreEqual(StatusCode.UnableToLocateNode.ToInt(), result.Value.StatusCode);
}
}
}
示例11: Client_Operations_Succeed_When_Bootstrapping_To_Pools_Default_Root_Uri
public void Client_Operations_Succeed_When_Bootstrapping_To_Pools_Default_Root_Uri()
{
var config = new CouchbaseClientConfiguration();
config.Urls.Add(new Uri("http://localhost:8091/pools/default"));
config.Bucket = "default";
var client = new CouchbaseClient(config);
string key = GetUniqueKey(), value = GetRandomString();
var storeResult = client.ExecuteStore(StoreMode.Add, key, value);
Assert.That(storeResult.Success, Is.True, "Success was false");
Assert.That(storeResult.Message, Is.Null.Or.Empty, "Message was not empty");
var getResult = client.ExecuteGet(key);
GetAssertPass(getResult, value);
}
示例12: Client_Operations_Succeed_When_Heartbeat_Is_Configured
public void Client_Operations_Succeed_When_Heartbeat_Is_Configured()
{
var config = new CouchbaseClientConfiguration();
config.Urls.Add(new Uri("http://localhost:8091/pools"));
config.Bucket = "default";
config.HeartbeatMonitor = new HeartbeatMonitorElement();
config.HeartbeatMonitor.Enabled = true;
config.HeartbeatMonitor.Interval = 100;
config.HeartbeatMonitor.Uri = "http://localhost:8091/pools";
var client = new CouchbaseClient(config);
string key = GetUniqueKey(), value = GetRandomString();
var storeResult = client.ExecuteStore(StoreMode.Add, key, value);
StoreAssertPass(storeResult);
var getResult = client.ExecuteGet(key);
GetAssertPass(getResult, value);
}
示例13: When_Flushing_Bucket_Data_Are_Removed
public void When_Flushing_Bucket_Data_Are_Removed()
{
var storedConfig = ConfigurationManager.GetSection("couchbase") as ICouchbaseClientConfiguration;
var config = new CouchbaseClientConfiguration();
config.Bucket = "Bucket-" + DateTime.Now.Ticks;
config.Username = storedConfig.Username;
config.Password = storedConfig.Password;
config.Urls.Add(storedConfig.Urls[0]);
var cluster = new CouchbaseCluster(config);
cluster.CreateBucket(new Bucket
{
Name = config.Bucket,
AuthType = AuthTypes.Sasl,
BucketType = BucketTypes.Membase,
Quota = new Quota { RAM = 100 },
ReplicaNumber = ReplicaNumbers.Zero,
FlushOption = FlushOptions.Enabled
}
);
for (int i = 0; i < 10; i++) //wait for bucket to be ready to accept ops
{
_bucket = waitForBucket(config.Bucket);
if (_bucket.Nodes.First().Status == "healthy") break;
Thread.Sleep(1000);
}
Assert.That(_bucket, Is.Not.Null);
using (var client = new CouchbaseClient(config))
{
var storeResult = client.ExecuteStore(StoreMode.Set, "SomeKey", "SomeValue");
Assert.That(storeResult.Success, Is.True, "Message: " + storeResult.Message);
var getResult = client.ExecuteGet<string>("SomeKey");
Assert.That(getResult.Success, Is.True);
Assert.That(getResult.Value, Is.StringMatching("SomeValue"));
cluster.FlushBucket(config.Bucket);
getResult = client.ExecuteGet<string>("SomeKey");
Assert.That(getResult.Success, Is.False);
Assert.That(getResult.Value, Is.Null);
}
}
示例14: When_Flushing_Bucket_Data_Are_Removed
public void When_Flushing_Bucket_Data_Are_Removed()
{
var config = new CouchbaseClientConfiguration();
config.Urls.Add(new Uri("http://10.0.0.79:8091/pools/default"));
config.Bucket = "default";
var client = new CouchbaseClient(config);
var storeResult = client.ExecuteStore(StoreMode.Set, "SomeKey", "SomeValue");
Assert.That(storeResult.Success, Is.True);
var getResult = client.ExecuteGet<string>("SomeKey");
Assert.That(getResult.Success, Is.True);
Assert.That(getResult.Value, Is.StringMatching("SomeValue"));
_Cluster.FlushBucket("default");
getResult = client.ExecuteGet<string>("SomeKey");
Assert.That(getResult.Success, Is.False);
Assert.That(getResult.Value, Is.Null);
}