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


C# CouchbaseClient.ExecuteStore方法代码示例

本文整理汇总了C#中CouchbaseClient.ExecuteStore方法的典型用法代码示例。如果您正苦于以下问题:C# CouchbaseClient.ExecuteStore方法的具体用法?C# CouchbaseClient.ExecuteStore怎么用?C# CouchbaseClient.ExecuteStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CouchbaseClient的用法示例。


在下文中一共展示了CouchbaseClient.ExecuteStore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

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

示例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);

            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

示例3: 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

示例4: 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

示例5: 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

示例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: When_Storing_A_Key_From_A_Down_Node_No_Exception_Is_Thrown_And_Success_Is_False

        public void When_Storing_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 storeResult = client.ExecuteStore(StoreMode.Set, "foo", "bar");

            Assert.That(storeResult.Success, Is.False);
            Assert.That(storeResult.Message, Is.StringContaining(ClientErrors.FAILURE_NODE_NOT_FOUND));
        }
开发者ID:robbygregory,项目名称:couchbase-net-client,代码行数:12,代码来源:CouchbaseClientStoreTests.cs

示例8: 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

示例9: 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

示例10: import

        private static void import(CouchbaseClient client, string directory)
        {
            var dir = new DirectoryInfo(directory);
            foreach (var file in dir.GetFiles())
            {
                if (file.Extension != ".json") continue;
                Console.WriteLine("Adding {0}", file);

                var json = File.ReadAllText(file.FullName);
                var key = file.Name.Replace(file.Extension, "");
                json = Regex.Replace(json.Replace(key, "LAZY"), "\"_id\":\"LAZY\",","");
                var storeResult = client.ExecuteStore(StoreMode.Set, key, json);
                Console.WriteLine(storeResult.Message);
            }
        }
开发者ID:couchbaselabs,项目名称:beernique-net,代码行数:15,代码来源:Program.cs

示例11: 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

示例12: 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

示例13: 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();
        }
开发者ID:evertonrlira,项目名称:CouchBaseLearning,代码行数:17,代码来源:Program.cs

示例14: 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

示例15: When_Using_Code_Config_And_HttpClient_Factory_Is_Not_Set_Operations_Succeed

        public void When_Using_Code_Config_And_HttpClient_Factory_Is_Not_Set_Operations_Succeed()
        {
            var config = new CouchbaseClientConfiguration();
            config.Urls.Add(new Uri("http://localhost:8091/pools"));
            Assert.That(config.HttpClientFactory, Is.InstanceOf<DefaultHttpClientFactory>());

            Assert.That(config, Is.Not.Null, "min-config section missing from app.config");
            Assert.That(config.HttpClientFactory, Is.InstanceOf<DefaultHttpClientFactory>());

            var client = new CouchbaseClient(config);
            var kv = KeyValueUtils.GenerateKeyAndValue("default_config");

            var result = client.ExecuteStore(StoreMode.Add, kv.Item1, kv.Item2);
            Assert.That(result.Success, Is.True, "Store failed: " + result.Message);

            var value = client.Get(kv.Item1);
            Assert.That(value, Is.StringMatching(kv.Item2));
        }
开发者ID:sdir456,项目名称:couchbase-net-client,代码行数:18,代码来源:DefaultCouchbaseClientConfigurationTests.cs


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