NET build Distributed Framework (II). NET under Windows to connect to Redis under Linux

Source: Internet
Author: User
Tags redis desktop manager redis server

And then the last verse says

First, modify the Reids configuration file

// Modify the IP  bind 127.0.0.1 in the Reids configuration file to 0.0.0.0vi/etc/redis/6379. conf//  Turn off Redis service REDISD stop// Restart Redis Service Note: If you have a service REDISD start startup, you may have a problem, so start redis-server/etc/redis/6379. conf &

Second, firewall port settings

// Open 6379 Port firewall-cmd--zone= public--add-port=6379/tcp--permanent// view ports that are already open firewall-cmd--list-ports// Restart firewall firewall-cmd--reload

Iii. Installing the Redis Desktop Manager management tools test

: Https://redisdesktop.com/download

Select Connect to Redis server, enter the IP address, then click Test Connection, and after successful enter the connection name, click OK

Iv. Open the Visual Studio selection file--New--Select the console app in the Project pop-up window

V. Right-click on the new project to select the Manage NuGet package installation Stackexchange.redis

VI. Create a new class RedisHelper.cs, and then call the last F5 run program in the Main method

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingStackexchange.redis;namespaceconsoleapp2{ Public  classRedishelper {Private  StaticConfigurationoptions configuration = Configurationoptions.parse ("192.168.1.11:6379"); Private Static ReadOnlyObject Locker =New Object(); Private StaticConnectionmultiplexer Redisconn;  Public Staticconnectionmultiplexer Getredisconn () {if(Redisconn = =NULL)            {                Lock(Locker) {if(Redisconn = =NULL|| !redisconn.isconnected) Redisconn=connectionmultiplexer.connect (configuration); }            }            returnRedisconn; }    }}

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespaceconsoleapp2{classProgram {Static voidMain (string[] args) {            varRedisconn =Redishelper.getredisconn (); vardb =redisconn.getdatabase (); BOOLresult = db. Stringset ("name","I'm Liu Mingjun .");            Console.WriteLine (result);        Console.read (); }    }}

NET build Distributed Framework (II). NET under Windows to connect to Redis under Linux

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.