redis命令 sudo service redis start sudo service redis stop sudo service redis restart ps -ef|grep redis ps aux|grep redis sudo kill -9 pid sudo redis-server /etc/redis/redis.conf redis-cli ping select n key通用命令: keys pattern keys * keys a* exists key1 type key del key1 key2 expire key seconds ttl key string类型: set key value setex key seconds value mset key1 value1 key2 value2 ppend key value get key mget key1 key2 hash命令: hset key field value hmset key field1 value1 field2 value2 ... hkeys key 获取指定key下hash的所有属性 hget key field hmget key field1 field2 ... hvals key hdel key field1 field2 ... list命令: lpush key value1 value2 rpush key value1 value2 linsert key before或after 现有元素 新元素 lrange key start stop lset key index value lrem key count value 将列表中前count次出现的值为value的元素移除 count > 0: 从头往尾移除 count < 0: 从尾往头移除 count = 0: 移除所有 set集合命令: sadd key member1 member2 smembers key srem key zset有序集合命令: zadd key score1 member1 score2 member2 zrange key start stop zrangebyscore key min max zscore key member zrem key member1 member2 zremrangebyscore key min max