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