Asp. Net Couchbase Memcached image and text installation and call Development

Source: Internet
Author: User
Tags couchbase

Install Server

Server: http://www.couchbase.com/download choose suitable for their own download and installation can be, I choose here is Win7 64.

If the following error occurs when installing the server, I encountered it during the installation of win7 64.

In this case, you can cancel the installation. Run regedit using the CMD command. Expand the HKEY_LOCAL_MACHINE \ Software \ Microsoft \ Windows \ CurrentVersion branch, find the key value "ProgramFilesDir" in the right area of the window, and set its original key value "C: change \ Program Files to "X: \ Program Files" to disable the registry.

I modified the edisk here because I still have a lot of space left on the edisk.

 

If the server is successfully installed, you can see it in the browser. If not, you need to manually access http: // localhost: 8091/index.html. I installed it on the local machine, so I can use localhost or IP address or hostname.

Click SETUP, set by default, and click Next, Next, and Next.

Enter basic information and continue with Next.

Here I enter the password 123456, continue Next, and finally complete the configuration to reach the page.

After the installation is complete, you can view it in the service.

Client call

Create a console application and install it through Nuget.

Compile the project and view the referenced dll file.

Simple call through code after reference

Copy codeThe Code is as follows:
Using Couchbase;
Using Couchbase. Configuration;
Using Enyim. Caching;
Using Enyim. Caching. Configuration;
Using Enyim. Caching. Memcached;
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
Using System. Threading. Tasks;

Namespace MemcachedTest
{
Class Program
{
Static void Main (string [] args)
{
// Configure the server
Var mbcc = new CouchbaseClientConfiguration ();
// Set various timeout times
Mbcc. SocketPool. ReceiveTimeout = new TimeSpan (0, 0, 2 );
Mbcc. SocketPool. ConnectionTimeout = new TimeSpan (0, 0, 4 );
Mbcc. SocketPool. DeadTimeout = new TimeSpan (0, 0, 10 );
// Use the default database
Mbcc. Urls. Add (new Uri ("http: // 127.0.0.1: 8091/pools/default "));

// Create a Client and load the Client Configuration
Var client = new CouchbaseClient (mbcc );
// Add a data entry
Var item = client. Cas (StoreMode. Add, "Test", "Hello World! ");
// Obtain the newly added data
Console. WriteLine (client. Get ("Test "));
Console. WriteLine ("complete! ");
Console. ReadLine ();
}
}
}




It is certainly okay to get the set cache value for the first time.

Now we will comment out the set value.

Copy codeThe Code is as follows:
Var item = client. Cas (StoreMode. Add, "Test", "Hello World! ");

The modified code is as follows:

Copy codeThe Code is as follows:
// Configure the server
Var mbcc = new CouchbaseClientConfiguration ();
// Set various timeout times
Mbcc. SocketPool. ReceiveTimeout = new TimeSpan (0, 0, 2 );
Mbcc. SocketPool. ConnectionTimeout = new TimeSpan (0, 0, 4 );
Mbcc. SocketPool. DeadTimeout = new TimeSpan (0, 0, 10 );
// Use the default database
Mbcc. Urls. Add (new Uri ("http: // 127.0.0.1: 8091/pools/default "));

// Create a Client and load the Client Configuration
Var client = new CouchbaseClient (mbcc );
// Add a data entry
// Var item = client. Cas (StoreMode. Add, "Test", "Hello World! ");
// Obtain the newly added data
Console. WriteLine (client. Get ("Test "));
Console. WriteLine ("complete! ");
Console. ReadLine ();

The running value is still obtained.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.