0
我遇到了麻煩,我想將在REDIS中定義的KEYS分配給redisClient.keys函數中的值,但我無法做到這一點,我試圖對控制檯進行日誌記錄,但得到的結果是正確的,但它不能從該鍵的外部讀取功能。如果你幫助我,我將不勝感激。如何將KEYS分配給client.keys()函數中的值?
const redis = require('redis');
const redisClient = redis.createClient();
var values ;
redisClient.flushall();
redisClient.hmset('Angelica', { "Blues Traveler": 3.5, "Broken Bells": 2.0, "Norah Jones": 4.5, "Phoenix": 5.0, "Slightly Stoopid": 1.5, "The Strokes": 2.5, "Vampire Weekend": 2.0 });
redisClient.hmset('Bill', { "Blues Traveler": 2.0, "Broken Bells": 3.5, "Deadmau5": 4.0, "Phoenix": 2.0, "Slightly Stoopid": 3.5, "Vampire Weekend": 3.0 });
redisClient.hmset('Dan', { "Blues Traveler": 3.0, "Broken Bells": 4.0, "Deadmau5": 4.5, "Phoenix": 3.0, "Slightly Stoopid": 4.5, "The Strokes": 4.0, "Vampire Weekend": 2.0 });
redisClient.hmset('Hailey', { "Broken Bells": 4.0, "Deadmau5": 1.0, "Norah Jones": 4.0, "The Strokes": 4.0, "Vampire Weekend": 1.0 });
redisClient.hmset('Jordyn', { "Broken Bells": 4.5, "Deadmau5": 4.0, "Norah Jones": 5.0, "Phoenix": 5.0, "Slightly Stoopid": 4.5, "The Strokes": 4.0, "Vampire Weekend": 4.0 });
redisClient.hmset('Sam', { "Blues Traveler": 5.0, "Broken Bells": 2.0, "Norah Jones": 3.0, "Phoenix": 5.0, "Slightly Stoopid": 4.0, "The Strokes": 5.0 });
redisClient.hmset('Veronica', { "Blues Traveler": 3.0, "Norah Jones": 5.0, "Phoenix": 4.0, "Slightly Stoopid": 2.5, "The Strokes": 3.0 });
redisClient.hmset('Chan', { "Blues Traveler": 5.0, "Broken Bells": 1.0, "Deadmau5": 1.0, "Norah Jones": 3.0, "Phoenix": 5, "Slightly Stoopid": 1.0 });
redisClient.keys('*', (err, responde) => {
redisClient.hmget(responde);
values=responde.toLocaleString()
console.log(responde.toLocaleString())
})
console.log(values)
是的。我注意到了,謝謝你,巴迪。 – Ordinaryus