3、原子性,所有的语句是一个整体,要么执行成功,要么失败
redis与mamcache不同之处:
数据结构:Memcache仅能支持简单的K-V形式,Redis支持的数据更多
多线程:Memcache支持多线程,Redis支持单线程,CPU利用Memcache利用率更高
持久化:Redis支持持久化,Memcache不支持持久化
分布式:Redis做主从结构,而Memcache服务器需要通过hash一致化来支撑主从结构
虚拟内存:Redis当物理内存使用完时,会将一些很久没有用的内存交换到磁盘,而Memcache采取的LUR策略,将一部分数据刷新掉
与其他key-value缓存产品的区别
Redis各种数据类型应用和实现方式
String:数据结构是简单的K-V类型,v可以是数据,也可以是数字(常用操作:set,get,decr,incr,mget)
set:sadd,spop,smembers,sunion,sinter
list :lpush/rpush,lpop/rpop,lpoprpush,lrange
hash:hset,hgetall,hget
zset:zadd,zrank,zrange,zrem,zcard
部署
============================================================
- 部署环境
| 操作系统 | ip地址 |
| — | — |
| CentOS Linux release 7.5.1804 | 192.168.10.11 /24 |
- 下载 redis 安装包
[root@localhost ~]# wget http://download.redis.io/releases/redis-2.8.17.tar.gz
- 解压
[root@localhost ~]# tar zvxf redis-2.8.17.tar.gz
- 安装好编译环境
[root@localhost ~]# yum -y install gcc c++
- 编译
[root@localhost ~]# cd redis-2.8.17
[root@localhost redis-2.8.17]# ls
00-RELEASENOTES deps README sentinel.conf
BUGS INSTALL redis.conf src
CONTRIBUTING Makefile runtest tests
COPYING MANIFESTO runtest-sentinel utils
[root@localhost redis-2.8.17]# make
这里因为有makefile,所以直接make,若果make 出现一下错误,则解决办法:
[root@localhost redis-2.8.17]# make MALLOC=libc
cd src && make all
make[1]: Entering directory `/root/redis-2.8.17/src’
CC adlist.o
In file included from adlist.c:34:0:
zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
#include <jemalloc/jemalloc.h>
^
compilation terminated.
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/root/redis-2.8.17/src’
make: *** [all] Error 2
[root@localhost redis-2.8.17]# ls
请在make后面加上MALLOC=libc,出现下一界面就ok
- 测试下编译环境
[root@localhost ~]# cd redis-2.8.17/src/
[root@localhost src]# make test
You need tcl 8.5 or newer in order to run the Redis test
make: *** [test] Error 1
[root@localhost src]#
解决方法:
[root@localhost src]# yum -y install tcl
接着等着编译……
\o/ All tests passed without errors!
Cleanup: may take some time… OK
这里似乎没有出错,but……=如果已近安装mysql,报错了,考虑修改一下内容:
[root@localhost redis-2.8.17]# ls
00-RELEASENOTES COPYING Makefile redis.conf sentinel.conf utils
BUGS deps MANIFESTO runtest src
CONTRIBUTING INSTALL README runtest-sentinel tests
[root@localhost redis-2.8.17]# vi tests/integration/replication-2.tcl
搜索after 将原有的1000 改大一点,比如:10000 即可