@orangeoctopus usecae中幾乎沒有問題。
Redis的127.0.0.1:6379> HMSET編號:4532143215432用戶名davejlong [email protected].com OK Redis的127.0.0.1:6379> HMSET用戶:davejlong ID 4532143215432電子郵件[email protected].com OK
這會重複,考慮添加新值並刪除&更新。
所以,我更喜歡這種
SET user:davejlong 1
HMSET user:1 username davejlong email [email protected]
1)在用戶名
redis.get('user:davejlong',function(err,id){
console.log('User Id of @davejlong: ' + id);
redis.hgetall('user:'+id,function(err,user){
console.log('User Data: ' + user);
})
})
2)在標識
的情況下的情況下
redis.hgetall('user:1',function(err,user){
console.log('User Data: ' + user);
})
我用「更緊湊的方式來做這個......」,但卻懶得打出來。 +1 –
@philpirozhkov哪一個... –
對不起,我錯過了這一點,因爲你沒有增加通過郵件查找的能力。 'SET用戶:[email protected].com 1' 你可以通過郵件找到 –