- Redis -> REmote DIctionary Server
Redis三个特点
- 支持数据持久化
- 支持string,list,set,zset,hash
- 支持master-slave模式数据备份
启动redis
1
redis-server &
查看redis是否启动
1
ps -ef | grep redis
关闭redis
1
shutdown
连接redis
1
redis-cli -h host -p port -a password
redis配置
- 修改配置的两种方式
- 修改redis.conf
- 通过redis-cli
config get
config set
- 修改配置的两种方式
redis数据类型
- string
- 命令 set get
- hash
- 命令 hmset hget
- list
- 命令 lpush lrange
- set
- 命令 sadd smembers
- zset
- 命令 zadd key score member
- string
- redis键命令
- DEL key
- DUMP key
- EXISTS key
- EXPIRE key seconds
- EXPIREAT key timestamp
- PEXPIRE key milliseconds
- PEXPIREAT key milliseconds-timestamp
- KEYS pattern
- MOVE key db
- PTTL key
- TTL key
- RANDOMKEY
- RENAME key newkey
- RENAMENX key newkey
- TYPE key
- string命令
- SET key value
- GET key
- GETRANGE key start end
- GETSET key value
- GETBIT key offset
- MGET key [key2..]
- SETBIT key offset value
- SETEX key seconds value
- SETNX key value
- SETRANGE key offset value
- STRLEN key
- MSET key value [key value …]
- MSETNX key value [key value …]
- PSETEX key milliseconds value
- INCR key
- INCRBY key increment
- INCRBYFLOAT key increment
- DECR key
- DECRBY key decrement
- APPEND key value
- hash命令
- HDEL key field1 [field2]
- HEXISTS key field
- HGET key field
- HGETALL key
- HINCRBY key field increment
- HINCRBYFLOAT key field increment
- HKEYS key
- HLEN key
- HMGET key field1 [field2..]
- HMSET key field1 value1 [field2 value2 …]
- HSET key field value
- HSETNX key field value
- HVALS key
- HSCAN key cursor [MATCH pattern] [COUNT count]
- list命令
- BLPOP key1 [key2 ] timeout
- BRPOP key1 [key2 ] timeout
- BRPOPLPUSH source destination timeout
- LINDEX key index
- LINSERT key BEFORE|AFTER pivot value
- LLEN key
- LPOP key
- LPUSH key value [value2 ]
- LPUSHX key value
- LRANGE key start stop
- LREM key count value
- LSET key index value
- LTRIM key start stop
- RPOP key
- RPOPLPUSH source destination
- RPUSH key value [value2 ]
- RPUSHX key value
- set命令
- SADD key member1 [member2 …]
- SCARD key
- SDIFF key1 [key2 …]
- SDIFFSTORE destination key1 [key2 …]
- SINTER key1 [key2 …]
- SINTERSTORE destination key1 [key2 …]
- SISMEMBER key member
- SMEMBERS key
- SMOVE source destination memeber
- SPOP key
- SRANDMEMBER key [count]
- SREM key member1 [member2 …]
- SUNION key1 [key2 …]
- SUNIONSTORE destination key1 [key2 …]
- SSCAN key cursor [MATCH pattern] [COUNT count]
- zset命令
- ZADD key score1 member1 [score2 memeber2 …]
- ZCARD key
- ZCOUNT key min max
- ZINCRBY key increment member