centos 7 redisとredisの基本知識のインストール
3344 ワード
詳細
EPELのインストール
redis-cli
redis共通コマンド
2.サーバ関連コマンド
redisの高度な応用
EPELのインストール
wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
rpm -ivh epel-release-7-5.noarch.rpm
yum install redis
systemctl start redis.service
systemctl status redis.service
systemctl enable redis.service
redis-cli
string
set name zouhuying
get name
setnx key 0,
setex
setex haircolor 10 red
setrange
zouhuiying/ setrange name 1 h /zhuhuiying
mset key mset name zouhuiying age 18
mesetnx
getset name haoning
getrang name 0 3 name 0-3
mget key
incr
incrby incrby age (+-)3( )
decr decrby
append append name hhh ,
strlen value
hashes
hset
hset myhash( ) field1( ) Hello
hsetnx setnx
hmset hmget
hincr hincrby
hdecr hdecrby
hexits
hlen
hdel
hmset user:001 age 66 height 178
hmget useer:001 age height
hdel user:001 age
hkeys hkeys user:001
hvals hvals user:001
hgetall user:001 keys and values
list ( )
: ( )
:
( )
push pop
lpush mylist zouhuiying( )
rpush mylist ying( )
lrange mylist 0 -1
linsert ( ) linsert mylist before "ying" "yingying"
lset lset mylist 0 "xiaoying"
lrem n value lrem mylist 1 "hello" 1 n= 0: n<0 :
ltrim: ltrim mylist 1 -1( ),
lpop rpop
rpoplpush ( , )
lindex: lindex mylist 0( 0 )
llen:llen mylist (mylist )
redis共通コマンド
1.
keys * keys
exists key key
del key
expire key time (key )
ttl key -1:
select (0-15)
move key (0-15)
persist:
randomkey key
rename
type key : key
2.サーバ関連コマンド
ping (PONG, ping )
echo echo
select
quit/exit/control-c
dbsize key
info:
config get key key
flushdb key
flushall key
redisの高度な応用
:redis.conf->requirepass mima redis-cli -a mima redis-cli auth mima
: redis.conf -> slaveof 192.168.139.213 6379( IP ) and masterauth mima( redis )and bind 0.0.0.0 (telnet )
:multi queued , 。exec :discard
:session1:set age 20/ watch age / multi/ set age 30/ exec( )
session2 set age 20
unwatch
: redis.conf -> save 9000 1 /var/lib/redis/dump.rdb ,
aof redis.conf ->appendonly yes->appendfsync always( , )/appendfsync everysec( 0/appendfsync no( os, , ) /var/lib/redis/dump.rdb
:subscribe tv1 /publish tv1 zouhuiying( session)
: vm-enabled