• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CouchbaseClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



CouchbaseClient类属于命名空间,在下文中一共展示了CouchbaseClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
 }
开发者ID:JebteK,项目名称:couchbase-net-client,代码行数:7,代码来源:CouchbaseClientMemcachedTests.cs


示例2: using

 bool ICacheManager.Set(string key, object value, DateTime expiry)
 {
     bool bRet = false;
     using (var client = new CouchbaseClient(config))
     {
         bRet = client.Store(Enyim.Caching.Memcached.StoreMode.Set, key, value, expiry);
     }
     return bRet;
 }
开发者ID:xqgzh,项目名称:Z,代码行数:9,代码来源:CouchCacheManager.cs


示例3: Index

        public ActionResult Index(string setupKey)
        {
			try
			{
				if (setupKey != ConfigurationManager.AppSettings["TapMapSetupKey"])
				{
					throw new ApplicationException("Invalid TapMapSetupKey.  Please review the appSetting \"TapMapSetupKey\" in Web.config");
				}

				var client = new CouchbaseClient();				

				var root = Path.Combine(Environment.CurrentDirectory, Server.MapPath("~/App_Data"));
				import(client, "brewery", root, "breweries.zip");
				import(client, "beer", root, "beers.zip");
				import(client, "user", root, "users.zip");
				import(client, "tap", root, "taps.zip");
				
				createViewFromFile(Path.Combine(root, @"views\UserViews.json"), "users");
				createViewFromFile(Path.Combine(root, @"views\BreweryViews.json"), "breweries");
				createViewFromFile(Path.Combine(root, @"views\BeerViews.json"), "beers");
				createViewFromFile(Path.Combine(root, @"views\TapViews.json"), "taps");

				ViewBag.Message = "Successfully loaded views and data";
				ViewBag.MessageColor = "green";
			}
			catch (Exception ex)
			{
				ViewBag.Message = ex.Message;
				ViewBag.MessageColor = "red";
			}

			return View();
        }
开发者ID:wondertrap,项目名称:TapMap,代码行数:33,代码来源:SetupController.cs


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

            //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


示例5: AAAA

        static void AAAA()
        {
            //ITranscoder tr = new JsonTranscoder();

            //Dump(tr.Serialize("a").Data);
            //Dump(tr.Serialize(null).Data);
            //Dump(tr.Serialize(1.0f).Data);
            //Dump(tr.Serialize(2.4d).Data);
            //Dump(tr.Serialize(08976543).Data);
            //Dump(tr.Serialize(new { A = "a", B = 2, C = true, D = new[] { 1, 2, 3, 4 } }).Data);

            //var o = tr.Deserialize(tr.Serialize(new Tmp { A = "a" }));

            //Console.WriteLine(tr.Deserialize(tr.Serialize((Single)1)).GetType());
            //Console.WriteLine(tr.Deserialize(tr.Serialize((Double)1)).GetType());

            var mbc = new CouchbaseClientConfiguration();
            mbc.Urls.Add(new Uri("http://192.168.47.128:8091/pools/default"));

            var c = new CouchbaseClient(mbc);

            //	for (var i = 0; i < 10; i++) c.Store(StoreMode.Set, "json_" + i, i + 100);
            //for (var i = 0; i < 10; i++) c.Store(StoreMode.Set, "binary_" + i, i + 100);

            //for (var i = 0; i < 1000; i++)
            //    c.Store(StoreMode.Set, "key_" + i, i);

            var r = c.GetView("test", "all").Limit(20);
            var tmp = c.Get(r);

            //Console.WriteLine(r.Count);
        }
开发者ID:vitaly-rudenya,项目名称:couchbase-net-client,代码行数:32,代码来源:Program.cs


示例6: Run

        public override void Run()
        {
            var config = new CouchbaseClientConfiguration();
            config.Urls.Add(new Uri("http://localhost:8091/pools/"));
            config.Bucket = "beer-sample";

            var client = new CouchbaseClient(config);

            Console.WriteLine("Breweries by_name, limited to 10 records");
            var view = client.GetView("breweries", "by_name").Limit(10);

            Console.WriteLine("Breweries by_name, output the keys");
            view = client.GetView("breweries", "by_name").Limit(10);
            foreach (var item in view)
            {
                Console.WriteLine("Key: " + item.ViewKey.First());
            }

            Console.WriteLine("Breweries by_name, query by key range (y or Y)");
            view = client.GetView("breweries", "by_name").StartKey("y").EndKey("z");
            foreach (var item in view)
            {
                Console.WriteLine("Key: " + item.ViewKey.First());
            }

            Console.WriteLine("Breweries by_name, output the keys (y only)");
            view = client.GetView("breweries", "by_name").StartKey("y").EndKey("Y");
            foreach (var item in view)
            {
                Console.WriteLine("Key: " + item.ViewKey.First());
            }
        }
开发者ID:ebay-snarwal,项目名称:DeveloperDay,代码行数:32,代码来源:08_Views.cs


示例7: Main

 static void Main(string[] args)
 {
     var client = new CouchbaseClient();
     var returnValue = client.Get("");
     System.Console.WriteLine("OUTPUT: - {0}", returnValue);
     System.Console.ReadLine();
 }
开发者ID:erlenda,项目名称:couchbasemvc4,代码行数:7,代码来源:Program.cs


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


示例9: ViewRunner

 public ViewRunner(CouchbaseClientConfiguration config)
 {
     if (_client == null)
     {
         _client = new CouchbaseClient(config);
     }
 }
开发者ID:BatsIhor,项目名称:couchbase-model-views,代码行数:7,代码来源:ViewRunner.cs


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


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


示例12: When_Using_App_Config_And_Design_Document_Name_Transformer_Is_Not_Set_Production_Mode_Is_Default

        public void When_Using_App_Config_And_Design_Document_Name_Transformer_Is_Not_Set_Production_Mode_Is_Default()
        {
            var config = ConfigurationManager.GetSection("min-config") as CouchbaseClientSection;
            var client = new CouchbaseClient(config); //client sets up transformer

            Assert.That(config.DocumentNameTransformer.Type.Name, Is.StringMatching("ProductionModeNameTransformer"));
        }
开发者ID:e-travel,项目名称:couchbase-net-client,代码行数:7,代码来源:DefaultCouchbaseClientConfigurationTests.cs


示例13: View_Operations_Succeed_When_Initialize_Connection_Is_True

 public void View_Operations_Succeed_When_Initialize_Connection_Is_True()
 {
     var config = ConfigSectionUtils.GetConfigSection<CouchbaseClientSection>("httpclient-config-initconn");
     var client = new CouchbaseClient(config);
     var view = client.GetView<City>("cities", "by_name", true).Stale(StaleMode.False);
     viewPass(view);
 }
开发者ID:eugentorica,项目名称:couchbase-net-client,代码行数:7,代码来源:HttpClientConfigTests.cs


示例14: Main

        private static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Connecting with Couchbase...");
                var couchbaseClient = new CouchbaseClient();

                var client = new StatsClient(couchbaseClient);

                Console.WriteLine("Obtaining statistics...");
                var stats = client.GetStats();

                Console.WriteLine("Storing...");
                var data = Serialize(stats);
                File.WriteAllText(ConfigurationManager.AppSettings["reportFilePath"], data);

                Console.WriteLine("Done!");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                Console.Write("Press enter to exit...");
                Console.ReadLine();
            }
        }
开发者ID:bardock,项目名称:CouchbaseItemsStats,代码行数:28,代码来源:Program.cs


示例15: Test_That_Starved_SocketPool_Sends_StatusCode_SocketPoolTimeout

        public void Test_That_Starved_SocketPool_Sends_StatusCode_SocketPoolTimeout()
        {
            try
            {
                s_cbClient = new CouchbaseClient("socket-timeout");

                List<Thread> workers = new List<Thread>();
                for (int i = 0; i < THREADS; i++)
                {
                    Thread t = new Thread(ThreadBody);
                    t.Priority = ThreadPriority.BelowNormal;
                    workers.Add(t);
                }
                foreach (Thread t in workers)
                {
                    t.Join();
                }
                Console.WriteLine();
                Console.WriteLine("done");
                Thread.Sleep(1000);
            }
            finally
            {
                s_cbClient.Dispose();
            }
        }
开发者ID:sdir456,项目名称:couchbase-net-client,代码行数:26,代码来源:StatusCodeTests.cs


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


示例17: GetBeer

 /// <summary>
 /// Retrieve the beer object by name
 /// </summary>
 /// <param name="beerName"></param>
 /// <returns></returns>
 public Beer GetBeer(string beerName)
 {
     using (CouchbaseClient client = new CouchbaseClient())
     {
         Beer beer = client.GetJson<Beer>(beerName);
         return beer;
     }
 }
开发者ID:volkanx,项目名称:BeerExplorer,代码行数:13,代码来源:BeerRepository.cs


示例18: CommandBase

        public CommandBase(CouchbaseClient client,
			string key,
			CbcOptions options)
        {
            Key = key;
            this.client = client;
            this.options = options;
        }
开发者ID:saakshimanocha,项目名称:cbc-net,代码行数:8,代码来源:CommandBase.cs


示例19: LeaderBoardController

        static LeaderBoardController()
        {
            var config = new CouchbaseClientConfiguration();
            config.Bucket = "default";
            config.Urls.Add(new Uri("http://192.168.2.1:8091/pools/"));

            _client = new CouchbaseClient(config);
        }
开发者ID:dodilp,项目名称:kinectcouchbase,代码行数:8,代码来源:LeaderBoardController.cs


示例20: GetBrewery

 /// <summary>
 /// Retrieve the brewery object by key
 /// </summary>
 /// <param name="breweryId"></param>
 /// <returns></returns>
 public Brewery GetBrewery(string breweryId)
 {
     using (CouchbaseClient client = new CouchbaseClient())
     {
         Brewery brewery = client.GetJson<Brewery>(breweryId);
         return brewery;
     }
 }
开发者ID:volkanx,项目名称:BeerExplorer,代码行数:13,代码来源:BreweryRepository.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Counter类代码示例发布时间:2022-05-24
下一篇:
C# Cosmos类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap