Because of the project needs, ready to start the NoSQL database, compared to finally decided to use Couchbase. Okay, let's get started:
Installation
Address: Http://www.couchbase.com/get-started-developing-nosql#Download_Couchbase_Server
Version: Enterprise Edition 4.5.1, Community Edition 4.1.0
System: Windows, Mac OSX
Enter a bunch of required items and start the download.
Windows installation
Configuration
There's nothing special to note next. Create a database password longer than 6 bits
Installation complete See Control interface
. NET Add NuGet Reference
Code configuration
var config = newclientconfiguration
{
Servers = newList<Uri>
{
NewUri("Http://192.168.27.101:8091/pools")
, newUri("Http://192.168.27.102:8091/pools")
, newUri("Http://192.168.27.103:8091/pools")}
,
Bucketconfigs = newDictionary<string, bucketconfiguration>
{
{
"Default",newbucketconfiguration{bucketname = "Distributed_cache", Password = "Secret" }
}
}
};
var cluster = newcluster(config);
Data processing
Using (var bucket = Cluster.openbucket ())
{
var document = Newdocument<dynamic>
{
Id = "Hello",
Content = new
{
Name = "Couchbase"
}
};
var upsert = bucket. Upsert (document);
If (Upsert. Success)
{
var get = bucket. getdocument<Dynamic> (document. ID);
Document = Get. Document;
var msg = string. Format ("{0} {1}!" , document. Id, document. Content.name);
Console. WriteLine (msg);
}
Console. Read ();
}
Couchbase Getting started with NoSQL for. Net