Get the App
SLTechnology News&Howtos  ›  Development  › 

How to install and use Asp.Net Couchbase Memcached

Shulou Source: shulou.com Published: 2022-06-03 07:41:06 10月12日 Update

This article mainly explains "how to install and use Asp.Net Couchbase Memcached". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian slowly and deeply to study and learn "how to install and use Asp.Net Couchbase Memcached" together!

Install Server

Server download address: www.couchbase.com/download Select the appropriate download installation can be, I choose here is Win7 64.

If the following error occurs on the installation server side, I encountered it during the win7 64 installation.

At this point, you can undo the installation. Run regedit via CMD command. Expand HKEY_LOCAL_MACHINE\Software\Microsoft\ Windows\ CurrentVersion branch, find the key named "ProgramFilesDir" in the right area of the window, change its original key "C:\Program Files" to "X:\Program Files", and close the registry.

I modified the E disk here, because I have quite a lot of space left on the E disk.

After the server is installed, if it is successful, it can be seen in the browser. If not then you need to manually visit http://localhost: 8091/index.html. I installed it locally, so I can use localhost, I can use IP or hostname.

Click SETUP, default settings, then click Next, Next, then go to the following

Simply enter the basic information and proceed to Next.

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

Of course, after installation can also be viewed in the service.

client calls

Create a console application and install it via Nuget.

After referencing, compile the project and view the referenced dll file

The reference is complete, and a simple call is made from code.

The copy 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 server

var mbcc = new CouchbaseClientConfiguration();

//Set various timeouts

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

var item = client.Cas(StoreMode.Add, "Test", "Hello World! ");

//Get the data you just added

Console.WriteLine(client.Get("Test"));

Console.WriteLine("Done! ");

Console.ReadLine();

}

}

}

The first time you run it, you'll have no problem getting cached values for your settings.

Now let's comment on this setting.

The copy code is as follows:

var item = client.Cas(StoreMode.Add, "Test", "Hello World! ");

The modified code is as follows

The copy code is as follows:

//configure server

var mbcc = new CouchbaseClientConfiguration();

//Set various timeouts

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

//var item = client.Cas(StoreMode.Add, "Test", "Hello World! ");

//Get the data you just added

Console.WriteLine(client.Get("Test"));

Console.WriteLine("Done! ");

Console.ReadLine();

Run it again and the value is still captured.

Thank you for reading, the above is "how to install and use Asp.Net Couchbase Memcached" content, after the study of this article, I believe we have a deeper understanding of how to install and use Asp.Net Couchbase Memcached, the specific use of the situation also needs to be verified. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Tags: Code service data configuration learning running content database time server problem plus one input selection success again branch zone right command Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Technology NVidia Linux Xiaomi