当前位置: 首页>>代码示例>>C#>>正文


C# CouchbaseClient.ExecuteGet方法代码示例

本文整理汇总了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);
                }
            });
        }
开发者ID:WhallaLabs,项目名称:couchbase-net-client,代码行数:29,代码来源:Program.cs

示例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);
                }
            }
        }
开发者ID:WhallaLabs,项目名称:couchbase-net-client,代码行数:28,代码来源:Program.cs

示例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);
        }
开发者ID:ebay-snarwal,项目名称:DeveloperDay,代码行数:59,代码来源:04_Retrieve.cs

示例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);
        }
开发者ID:eugentorica,项目名称:couchbase-net-client,代码行数:11,代码来源:ConfigHelperTests.cs

示例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));
        }
开发者ID:rrmayer,项目名称:couchbase-net-client,代码行数:12,代码来源:CouchbaseClientGetTests.cs

示例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);
        }
开发者ID:e-travel,项目名称:couchbase-net-client,代码行数:12,代码来源:HeartbeatConfigTests.cs

示例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);
        }
开发者ID:eugentorica,项目名称:couchbase-net-client,代码行数:13,代码来源:ConfigHelperTests.cs

示例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);
            }
        }
开发者ID:JebteK,项目名称:couchbase-net-client,代码行数:13,代码来源:HeartbeatConfigTests.cs

示例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);
        }
开发者ID:sfoutrier,项目名称:couchbase-net-client,代码行数:15,代码来源:ConfigHelperTests.cs

示例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);
                }
            }
        }
开发者ID:sdir456,项目名称:couchbase-net-client,代码行数:16,代码来源:CouchbaseClientGetTests.cs

示例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);
        }
开发者ID:sfoutrier,项目名称:couchbase-net-client,代码行数:16,代码来源:ConfigHelperTests.cs

示例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);
        }
开发者ID:sfoutrier,项目名称:couchbase-net-client,代码行数:19,代码来源:HeartbeatConfigTests.cs

示例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);
            }
        }
开发者ID:sdir456,项目名称:couchbase-net-client,代码行数:47,代码来源:CouchbaseClusterBucketAdminTests.cs

示例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);
        }
开发者ID:e-travel,项目名称:couchbase-net-client,代码行数:21,代码来源:CouchbaseClusterBucketAdminTests.cs


注:本文中的CouchbaseClient.ExecuteGet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。