本文整理汇总了C#中CouchbaseClient类的典型用法代码示例。如果您正苦于以下问题:C# CouchbaseClient类的具体用法?C# CouchbaseClient怎么用?C# CouchbaseClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CouchbaseClient类属于命名空间,在下文中一共展示了CouchbaseClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例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();
}
示例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");
}
示例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);
}
示例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());
}
}
示例7: Main
static void Main(string[] args)
{
var client = new CouchbaseClient();
var returnValue = client.Get("");
System.Console.WriteLine("OUTPUT: - {0}", returnValue);
System.Console.ReadLine();
}
示例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);
}
});
}
示例9: ViewRunner
public ViewRunner(CouchbaseClientConfiguration config)
{
if (_client == null)
{
_client = new CouchbaseClient(config);
}
}
示例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);
}
}
}
示例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");
}
示例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"));
}
示例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);
}
示例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();
}
}
示例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();
}
}