memchache的缺点
纯内存的操作数据库关机全部丢失保纯字节数据,数据类型缺乏 ruby写 ruby读lru算法导致数据库不可控一致性处理简单应用端太厚, 服务端太薄应用场景有限,难以被看成是完整的数据库产品redis用C 实现bsd许可简直存储支持丰富的类型非常适合表达时间线的活动如微博+数组形式的频繁删除和添加特点内存+磁盘的持久化保存具有丰富的数据类型 尤其是擅长数组类型的保存高速处理 字符串 链表 集合, 有序集合 散列表数据快照自带主从复制在centos上安装redis[root ~]# yum install redisLoaded plugins: fastestmirror, refresh-packagekit, securityDetermining fastest mirrors * base: mirrors.pubyun.com * extras: mirrors.pubyun.com * updates: mirrors.pubyun.com 不能安装redis wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm12:00 nosql03b[root ~]# rpm -ivh epel-release-6-8.noarch.rpm[root ~]# yum install redis[root ~]# find / -name "redis*";/var/lib/redis/var/run/redis/var/log/redis/usr/bin/redis-cli/usr/bin/redis-check-dump/usr/bin/redis-benchmark/usr/bin/redis-check-aof/usr/sbin/redis-server/usr/share/doc/redis-2.4.10/etc/redis.conf/etc/rc.d/init.d/redis/etc/logrotate.d/redis[root soft]# cat /etc/redis.confhttp://blog.csdn.net/vv_demon/article/details/7676384daemonize yes程序后台化运行port 6379 redis01.conf redis01.conf 并且port不同bind绑定iptimeout 0关闭这项功能slaveof主从复制19:36源码安装[root@localhost ~]# wget http://download.redis.io/releases/redis-2.0.4.tar.gz在另外一个server[root@localhost ~]# tar -zxvf redis-2.0.4.tar.gz[root@localhost ~]# cd redis-2.0.4[root@localhost ~]#make [root@localhost ~]#make install[root@localhost redis-2.0.4]# cp ./redis-server /usr/local/bin[root@localhost redis-2.0.4]# cp ./redis.conf /etc[root@localhost redis-3.0.3]# redis-server /etc/redis.conf[root@localhost redis-2.0.4]# vi /etc/redis.confdaemonize yes[root@localhost redis-2.0.4]# redis-server /etc/redis.conf [root@localhost redis-2.0.4]# telnet localhost 6379另外开一个客户端[root@localhost redis-3.0.3]# telnet localhost 6379Trying ::1...telnet: connect to address ::1: Connection refusedTrying 127.0.0.1...telnet: connect to address 127.0.0.1: Connection refused[root@localhost redis-3.0.3]# telnet localhost 6379Trying ::1...Connected to localhost.Escape character is '^]'.set fuge 4hell+OKsetex foo 5 3设置过期时间五秒之后就没有了123get foo$-1lpush data 3foo:1lpush data 3bar:2lrange data 0 -1从头至尾*2$3bar$3foodel data:1zadd sets 1 4hoga:1zadd sets 2 4fuga :1zadd sets 3 3foo:1zrange sets 0 -1*3$4hoga$4fuga$3fpaohaijiao@ubuntu:~$ sudo apt-get install rubypaohaijiao@ubuntu:~$ sudo gem install redispaohaijiao@ubuntu:~$ sudo gem install system_timerredis支持链表的操作lpush <[][][]>rpushlrange data 0 -1从头至尾del data zadd sets 1 409:42 nosql 03c[root@localhost ~]# yum install ruby[root@localhost ~]# yum install rubygems[root@localhost ~]# gem install SystemTimer[root@localhost ~]# uname -aLinux localhost.localdomain 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux[root@localhost ~]# yum install system_timerrequire 'rubygem'require 'redis'redis=Redis.newredis2=Redis.newredis.lpush:hoge,3redis.lpush:hoge,2redis.lpush:hoge,1redis.rpush:hoge,4p redis.lrange:hoge,0,-1ctrl+d nosqlb