1. Introduction
1.1 Basic introduction
String is the most commonly used data type of Redis, where the key value is a string, and the value value can be a string or numeric type.
The external presentation structure is similar to the Map<String, String>/Map<String, Number> collection in Java
The value value in it has a kind of implementation (type internal encoding)
int: 8-byte long integer
embstr: string less than or equal to 39 bytes
raw: strings larger than 39 bytes
Redis will decide which internal encoding implementation to use based on the type and length of the current value, for example:
#存短字符串
127.0.0.1:6379> set name dafei
OK
#查看类型真实编码
127.0.0.1:6379> object encoding name
"embstr"
#存int类型
127.0.0.1:6379> set age 18
OK
127.0.0.1:6379> object encoding age
"int"
#存长字符
127.0.0.1:6379> set content 11111111111111.....aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
OK
12