1: Both the mobile phone number and the ID number are unique. Choose either one as the key for user information. For example, use the mobile phone number mobile as the key and use a hash structure; mobile->hash 2: Create an ID card and The corresponding relationship between mobile phone numbers uses the string structure: id->mobile 3: User data can be directly queried with the mobile phone number. If you use an ID card, first find the corresponding mobile phone number, and then get the hash data based on the mobile phone number;
Personally, I think you can use Hash to save. For example, user A has a mobile phone number of 123 and an ID number of 456. The key can be in the form of A:手机号或者A:身份证号.
That’s okayHSET A:123 phone 123 id 456或者HSET A:456 phone 123 id 456.
Ideal situation: Regardless of the foreigner’s ID card and mobile phone number, your idea is totally fine. Map both the ID card number and mobile phone number to the key. When calling this key, if the key is 15 or 18 digits, it is the ID card, and 11 digits is the mobile phone number. It is OK to judge the length. But in actual applications, it is recommended to store these two fields separately.
The following ideas are for reference only:
1: Both the mobile phone number and the ID number are unique. Choose either one as the key for user information. For example, use the mobile phone number mobile as the key and use a hash structure;
mobile->hash
2: Create an ID card and The corresponding relationship between mobile phone numbers uses the string structure: id->mobile
3: User data can be directly queried with the mobile phone number. If you use an ID card, first find the corresponding mobile phone number, and then get the hash data based on the mobile phone number;
Personally, I think you can use Hash to save. For example, user A has a mobile phone number of 123 and an ID number of 456. The key can be in the form of
A:手机号
或者A:身份证号
.That’s okay
HSET A:123 phone 123 id 456
或者HSET A:456 phone 123 id 456
.Ideal situation: Regardless of the foreigner’s ID card and mobile phone number, your idea is totally fine. Map both the ID card number and mobile phone number to the key. When calling this key, if the key is 15 or 18 digits, it is the ID card, and 11 digits is the mobile phone number. It is OK to judge the length.
But in actual applications, it is recommended to store these two fields separately.