. NET using Redis windows to install C #

Source: Internet
Author: User
Tags download redis redis download redis windows

Redis is a widely used Key/value memory database that is used as a cache in large applications such as Sina Weibo, Github, StackOverflow, and Redis's official website is http://redis.io/.

Redis is needed in recent projects, where you can simply record the installation of Redis and how to do it. NET, using Redis.

Redis installation and startup 1. Download Redis

Redis itself does not provide a version of Windows, and it is not stable on windows, it is generally deployed to a Linux environment, Redis can be downloaded on its official website, Msopentech is available in the Windows version, here in order to learn to install this version.

Click Jump to GitHub and click Zip to download. After downloading, choose either 32-bit or 64-bit to install according to the version of your computer. I put the 64-bit decompression into the D:\Redis folder, and also copy the redis.conf in the folder to this directory, this is the configuration information of Redis:

2. Start Redis

Like enabling Redis and starting Mogodb under Windows, you need to start with a command line, navigate to that directory, and run the following command:

D:\redis>redis-server.exe redis.conf

Because it is running natively, pay attention to the port number and keep the ports from shutting down.

Of course, you can also keep redis open in the background as a Windows service.

3. Use

Now open a console application before connecting the Redis that was started, as follows:

D:\redis>redis-cli.exe-h 172.16.147.121-p 6379

Where –h is followed by the native IP address, followed by the port.

You can then execute set to assign the key to city:

Redis 172.16.147.121:6379> Set City Shanghai

Get allows you to get the value of the specified key as city.

Redis 172.16.147.121:6379> Get City

At the same time, when we write data to Redis, the Redis service also periodically writes data to the file.

The get and set commands are simply described here, and more commands are available to view the Http://redis.io/commands

. Explore Redis Download Servicestack.redis

Like MongoDB, using Redis in. NET is actually using a third-party driver, and it is recommended to use Servicestack.redis to download and extract the following DLLs.

. NET project, using Redis

Create a new console program that references the four DLLs extracted from the previous step.

To do a simple example, get the value of city before we set it in. Net.

class Program{    Staticredisclientredisclient =Newredisclient("172.16.147.121", 6379);//redis Service IP and Portsstatic voidMain (string[] args) {        Console. WriteLine (redisclient.get<string> ("City")); Console.    ReadKey (); }}

First through the static redisclient redisclient = new Redisclient ("172.16.147.121", 6379);

Establish a connection, and then you can use the Get method inside the redisclient to get the value of key city.

In the previous command line, we saved Shanghai in the city, and now we get this value.

There are many ways to call serverstack in. NET, and its class structure diagram is as follows:

Summarize

This article briefly describes how Redis,redis installs under Windows, and how to do it in. NET to access and use Redis, I hope to help you, the following will explain how to. NET Redis to read and write complex objects.

Source:http://www.cnblogs.com/yangecnu/

. NET using Redis windows to install C #

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.