C # Operations Redis

Source: Internet
Author: User
Tags install redis redis server

Redis is a non-relational, high-performance Key-value database. In some cases can be a good complement to the relational database. It provides clients such as Java,c/c++,c#,php,javascript,perl,object-c,python,ruby,erlang, which is convenient to use.

Redis offers five types of data: String,hash,list,set and Zset (sorted set).

Well, don't say much, install Redis first. The version I provide here is the 64-bit 3.2.1.00 Https://files.cnblogs.com/files/wangjifeng23/Redis-x64-3.2.100.zip, the remaining version can be downloaded to the official website/HTTP/ Download.redis.io/releases/.

After downloading, create a new folder and unzip the file.

Once the extraction is complete, the Redis installation begins.

1. Type cmd

2. Point to Redis installation path F:-CD Redis

3.redis Installation Instructions Redis-server redis.windows.conf, appears to be installed successfully

Open the Redis Client tool (Redis-cli.exe)

Use the set get settings to get the value, as shown below, even with a successful

Well, for ease of use, we can deploy Redis to services and then use the third-party client software redisdesktopmanager (download link: https://pan.baidu.com/s/ 1dawfwlzqk0ajphoqehqaxa Password: jr5r) to manage, make development more convenient.

Use the cmd type command as shown above: redis-server--service-install redis.windows.conf

Open the client, create the connection, enter localhost (native service), make sure the Redis service is turned on, and Port 6379 (primary server) before connecting

As shown to prove that we are connected successfully, on the left is my stored 4 key value pairs of data.

Well, next we're going to implement the storage and capture of it in the code.

Using NuGet to install Servicestack.redis, this is what Microsoft has packaged for Redis operations classes. Contains 4 DLLs

Connect to Redis server, read and store

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;namespaceredis{ Public Partial classLogin:System.Web.UI.Page {protected voidPage_Load (Objectsender, EventArgs e) {        }         Public StaticServiceStack.Redis.RedisClient client =NewServiceStack.Redis.RedisClient ("127.0.0.1",6379);  Public voidLoginObjectsender, EventArgs e) {            //Read            stringName = client. get<string> ("name"); stringPWD = client. get<string> ("Password"); //StorageClient. set<string> ("name1", username.            Value); Client. Set<string> ("Password1", Userpwd.        Value); }    }}

Summarize:

1, Redis not only supports simple k/v type of data, but also provides the storage of data structures such as List,set,zset,hash.
2, Redis support data backup, that is, Master-slave mode of data backup.
3, Redis support data persistence, you can keep the in-memory data on the disk, restart the time can be loaded again for use.
4, Redis can achieve master-slave replication, to achieve fault recovery.
5. Redis's sharding technology: it's easy to distribute data across multiple Redis instances

Reprint please indicate the source

C # Operations Redis

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.