First, install a Ubuntu Virtual Machine to install redis. Ubuntu unity is stuck in the virtual machine. You can install the traditional gnome interface as follows:
Sudo aptitude install gnome-session-Fallback
After the installation is complete, you can select the gnome interface at the logon location.
Redis compilation and installation in Linux is very simple. Access redis. Io to obtain the stable version of the source code. Redis-2.8.13.tar.gz
After the download is complete, run the following command:
Tar xzf redis-2.8.13.tar.gz
CD redis-2.8.13
Make
Sudo make install
Make install will copy the compiled program to/usr/local/bin. Execute Command
Redis-server can start the redis server. The default port is 6379. You can test it with the built-in client,
[Email protected]: ~ $ Redis-cli-H 127.0.0.1-P 6379
127.0.0.1: 6379> Ping
Pong
127.0.0.1: 6379> set Bar 1
OK
127.0.0.1: 6379> keys *
1) "bar"
127.0.0.1: 6379> exists bar
(Integer) 1
127.0.0.1: 6379> exists n
(Integer) 0
Wagner. 0.0.1: 6379> del bar
(Integer) 1
OK. Everything is normal.
There are various languages on the http://redis.io/clients page client, C # there are also a lot of, more commonly used is servicestack. redis, this client can be in nuget or get, can also be downloaded from GitHub.
After the dependencies are installed, you can write a simple C # program to test the virtual machine's IP address is 192.168.79.128:
class Program { static void Main(string[] args) { var client = new RedisClient("192.168.79.128", 6379); client.Set<string>("user", "HelloRedis"); client.Set<int>("Age", 23); Console.WriteLine("Getting Data from Redis \r\n Name:{0}; Age:{1}.", client.Get<string>("user"), client.Get<int>("Age")); Console.ReadLine(); } }
Output result:
Go back to the VM and check the redis service:
[Email protected]: ~ $ Redis-cli-H 127.0.0.1-P 6379
127.0.0.1: 6379> keys *
1) "Age"
2) "user"
More to learn e ......