hstrlen
1. 基本語法
hstrlen(hkey, subkey, callback)
hkey, subkey, callback) 回傳hkey底下subkey對應資料的字符串長度。該用法類似String資料的strlen指令。
2. 範例
(1) 查詢英數字字符串長度
const dict = {
name: 'Lester Burnham',
gender: 'M',
age: '42',
hobby : 'Workout'
};
client.hmset('user:3', dict);
client.hstrlen('user:3', 'name', redis.print);Reply: 14(2) 中文字符串長度
中文字符串為UTF-8編碼,一個UTF-8編碼的中文字符佔3個字節(Byte),因此長度為3
Last updated
Was this helpful?