[hadoop@hadoop1 ~]$ cd /opt/module/redis/bin
[hadoop@hadoop1 bin]$ redis-server redis.conf
[hadoop@hadoop1 bin]$ redis-cli
127.0.0.1:6379> set num1 123456
OK
127.0.0.1:6379> set num2 1234567
OK
127.0.0.1:6379> set num3 12345678
OK
127.0.0.1:6379> strlen num1 (integer) 6 127.0.0.1:6379> strlen num2 (integer) 7 127.0.0.1:6379> strlen num3 (integer) 8
127.0.0.1:6379> incr num1 (integer) 123457 127.0.0.1:6379> incr num1 (integer) 123458
127.0.0.1:6379> decr num1 (integer) 123457 127.0.0.1:6379> decr num1 (integer) 123456
127.0.0.1:6379> incrby num1 3 (integer) 4 127.0.0.1:6379> incrby num1 3 (integer) 7
127.0.0.1:6379> decrby num1 2 (integer) 5 127.0.0.1:6379> decrby num1 2 (integer) 3
127.0.0.1:6379> getrange num1 0 -1 "123456" 127.0.0.1:6379> getrange num1 0 1 "12" 127.0.0.1:6379> getrange num1 0 100 "123456"
127.0.0.1:6379> set num1 13718484108
OK
127.0.0.1:6379> setrange num1 3 ****
(integer) 11
127.0.0.1:6379> get num1
"137****4108"
这也就是手机号码脱敏
127.0.0.1:6379> setex num1 10 123456 OK 127.0.0.1:6379> get num1 "123456" 127.0.0.1:6379> ttl num1 (integer) 3 127.0.0.1:6379> ttl num1 (integer) -2 127.0.0.1:6379> get num1 (nil)