Use of redis
1. Install redis official site steps install redis (http://redis.io/download)
$ wget http://download.redis.io/releases/redis-2.8.15.tar.gz$ tar xzf redis-2.8.15.tar.gz$ cd redis-2.8.15$ make
2. Start redis
$ src/redis-server
Or
Start the background
nohup src/redis-server &
Process
[1] 16461
Interesting tips
[email protected]:/srv/rorapps/redis/redis-2.8.15# src/redis-server [16445] 16 Sep 09:54:32.684 # Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf[16445] 16 Sep 09:54:32.686 * Increased maximum number of open files to 10032 (it was originally set to 1024). _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 2.8.15 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in stand alone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 16445 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' [16445] 16 Sep 09:54:32.688 # Server started, Redis version 2.8.15[16445] 16 Sep 09:54:32.688 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.[16445] 16 Sep 09:54:32.688 * The server is now ready to accept connections on port 6379
OK, the above redis server is complete
3. Client usage
This section describes how to use rails.
Gem
Redis-Rb (https://github.com/redis/redis-rb)
require "redis"redis = Redis.newredis.set("mykey", "hello world")# => "OK"redis.get("mykey")# => "hello world"
OK, simple Client Version
4. troubleshoot
Prompt
Redis::ProtocolError ( Got 'H' as initial reply byte. If you're in a forking environment, such as Unicorn, you need to connect to Redis after forking. ):
Your redis service is not started.
Redis icons are quite interesting.