Build your Redis environment and set up a. NET HelloWorld program Test (GO)

Source: Internet
Author: User
Tags download redis

About Redis, the following from Baidu Encyclopedia:

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 HASHS (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 the python,ruby,erlang,php client, which is very convenient to use.

The last time I tested Memcached, I decided to try this Redis today.

Because Redis deployments are better than windows in a Linux environment, they are intended to be deployed in a virtual machine Ubuntu environment and then tested under Windows 8.

1. Go to the official website to download Redis decompression and installation, I downloaded the 2.8.0-rc2.

$ wget http://redis.googlecode.com/files/redis-2.6.15.tar.gz$ tar xzf redis-2.6.15.tar.gz$ cd redis-2.6.15$ make

2. After compiling the executable file in the SRC directory, you can run Redis using the following command:

$ src/redis-server

3. You can use the built-in client to connect to Redis:

$ src/redis-cliredis> set foo barokredis> get foo "bar"

4. Create a new. NET program test under Windows.

If you can't connect.

In case of success

Test code:

Using system;using system.collections.generic;using system.linq;using system.text;using ServiceStack.Redis;using            System.threading;namespace redistutorial{class Program {static void Main (string[] args) { using (var redisclient = redismanager.getclient ()) {using (var cars = Redisclient.gettypedclie Nt<car> ()) {if (cars). GetAll (). Count > 0) cars.                    DeleteAll (); var Dansford = new Car {Id = cars.                    Getnextsequence (), Title = "Zhang San car", make = new Make {name = "BMW"}, model = new Model {name = "Mercedes"}}; var Beccisford = new Car{id = cars.                    Getnextsequence (), Title = "John Doe Car", make = new Make {name = "Honda"},model = new Model {name = "Ford"}}; var Vauxhallastra = new Car{id = cars.                    Getnextsequence (), Title = "Harry Car", make = new Make {name = "BYD"},model = new Model {name = "GENERIC"}}; var Vauxhallnova = newCar{id = cars.                    Getnextsequence (), Title = "Zhao Liu car", make = new Make {name = "VW"},model = new Model {name = "Audi"}};                    var carstostore = new List<car> {dansford, Beccisford, Vauxhallastra, Vauxhallnova}; Cars.                    StoreAll (Carstostore); Console.WriteLine ("Redis has," + cars.) GetAll (). Count + "car.                    "); Cars.                    Expireat (Vauxhallastra.id, DateTime.Now.AddSeconds (5));                     Thread.Sleep (6000); Console.WriteLine ("Redis has," + cars.) GetAll (). Count + "car.                    "); var Carsfromredis = cars. GetAll (). Where (car = car.                    Make.name = = "BYD"); foreach (var car in Carsfromredis) {Console.WriteLine ("Redis has," + car.                    Title);        }}} console.readline ();        }} public class Car {public long Id {get; set;} public string Title {get;Set        public string Description {get; set;}        Public make make {get; set;}    Public model model {get; set;}        public class ' make ' {public int Id {get; set;}    public string Name {get; set;}        public class Model {public int Id {get; set;}        Public make make {get; set;}    public string Name {get; set;} }}

Configuration file:

<?xml version= "1.0"?><configuration>  <configSections>    <section name= "Redisconfig" Type= "Redistutorial.redisconfiginfo, redistutorial"/>  </configSections>  <redisconfig Writeserverlist= "192.168.77.27:6379"                readserverlist= "192.168.77.27:6379"                maxwritepoolsize= "                Maxreadpoolsize= "               autostart=" true "                localcachetime=" "                recordelog=" false ">       </ redisconfig><startup>  <supportedruntime version= "v4.0" sku= ". netframework,version=v4.0 "/></startup></configuration>


Test code Download: Click I download

Reference: Servicestack.redis Use tutorial

Other resources:

Redis applications in the. NET Architecture (1)--connect Redis with Servicestack

Thanks for browsing!

Build your Redis environment and set up a. NET HelloWorld program Test (GO)

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.