Redis Simple Understanding (C #)

Source: Internet
Author: User

Redis

Redis is an open source API that is written in ANSI C, supports the web, can be persisted in memory, key-value databases, and provides multiple languages.

Redis is a key-value storage system. Similar to memcached, it supports storing more value types, including string (string), list (linked list), set (set), Zset (sorted set-ordered collection), and hash (hash type). These data types support Push/pop, Add/remove, and intersection-set and difference sets, and richer operations, and these operations are atomic. Based on this, Redis supports sorting in a variety of different ways. As with memcached, data is cached in memory to ensure efficiency. The difference is that Redis periodically writes the updated data to disk or writes the modified operation to the appended record file, and Master-slave (Master-Slave) synchronization is implemented on this basis.

Redis is a high-performance Key-value database. The emergence of Redis, to a large extent, compensates for the lack of memcached such key/value storage, 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 supports master-slave synchronization. Data can be synchronized from the primary server to any number of slave servers, from the server to the primary server that is associated with other slave servers. This enables Redis to perform single-layer tree replication. You can write to the data intentionally or unintentionally. Because of the full implementation of the publish/subscribe mechanism, you can subscribe to a channel and receive a complete message release record from the master server when the tree is synchronized anywhere from the database. Synchronization is helpful for the scalability and data redundancy of read operations.Installation and TestingMy side is windows7. Installation Address: Https://github.com/dmajkic/redis/downloads extract to any directory, double-click Run Resis-server.exe test needs to execute Redis-cli.exe You can also register Resis-server.exe with the Windows service and need to download the service installation Component Https://github.com/rgl/redis/downloads start Service post test (get set) so that the installation is completeC # ImplementationCreate a C # project, add Redis related references, use Microsoft recommended Servicestack.redis, recommend using VS2013, or the installation will fail.
Using servicestack.redis;using system;using system.collections.generic;using system.linq;using System.Text;using System.threading;namespace testredis{class Program {static void Main (string[] args) {Poo            Ledredisclientmanager PRCM = Createmanager (); Read-write client using (iredisclient Redis = prcm. Getclient ()) {Redis.set ("test", "TestValue" + DateTime.Now.ToString (), DateTime.Now.AddDays (10)            ); }//Read-only client using (iredisclient Redis = prcm.            Getreadonlyclient ()) {Console.WriteLine (redis.get<string> ("Test"));            } Console.WriteLine ("-----");            Thread.Sleep (15000);            Console.WriteLine ("-----"); using (iredisclient Redis = prcm.            Getreadonlyclient ()) {Console.WriteLine ("After 15 seconds:" + redis.get<string> ("test"));        } console.read (); } public static PooledRedisclientmanager Createmanager () {//support read/write separation, load balancing, load balancing requires separate deployment of return new Pooledredisclientman Ager (new string[] {"10.58.8.239:6379"}//for Write, new string[] {"10.58.8.239:6379"}//for reading, n  EW redisclientmanagerconfig {maxwritepoolsize = 10,//"write" link pool link Number maxreadpoolsize =        10,//"write" link pool link Number AutoStart = true,}); }    }}

The source of the Buddhist monk: http://www.cnblogs.com/woxpp/p/5007623.html This copyright belongs to the author and the blog Park is shared, welcome reprint, but without the author's consent must retain this paragraph, and in the article page obvious location to the original link.

Redis Simple Understanding (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.