1、配置后台运行
在redis根目录下,打开redis配置文件
vi redis.conf
找到:daemonize将其修改为yes
esc
退出,:wq
保存退出。
测试:
# 启动服务
./redis-server ../redis.conf
# 查看进程
ps -ef|grep redis
2、redis关闭服务
我们需要打开redis-cli
# 关闭服务
shutdown
# 退出
exit
3、压力测试
# 100个客户端并发 10000个请求
./redis-benchmark -c 100 -n 10000
每秒处理4到5万个请求。
需要说明的是,redis是单线程的,它的性能极限与内存有关。
4、redis默认有16个数据库
默认使用第0个数据库
# 切换到4号数据库
select 3
# 清空当前数据库数据
flushdb
# 清空所有数据库数据
flushall
5、redis-key
# set key value 存数据
set name butcher
# get key 取数据
get name
# 查看所有key
keys *
# exists key 判断key是否存在
exists name
# 设置过时时间 expire key secound
expire name 10
# 移动key为name的值到下标1号数据库
move name 1