hmget & hmset
1. 基本語法
(1) hmset(hkey
,subkey, value[, subkey, value, ...]
, callback
)
hkey
,subkey, value[, subkey, value, ...]
, callback
) 為hkey
一次設置多組subkey
與value
的鍵值對資料。
(2) hmget(hkey
, subkey[, subkey, ...]
,callback
)
hkey
, subkey[, subkey, ...]
,callback
) 回傳hkey
底下多組subkey
對應的資料內容。
const dict = {
name: 'Brooks Hatlen',
gender: 'M',
age: '73'
};
client.hmset('user:2', dict);
client.hmget('user:2', 'name', 'age', (err, vals) => {
console.log(vals);
});
[ 'Brooks Hatlen', '73' ]
Last updated
Was this helpful?