Client.hgetall(key)
返回存储在 key
处的哈希的所有字段和值。
参数
参数 | 类型 | 描述 |
---|---|---|
key | string | 包含要获取字段的哈希的 key。 |
返回值
类型 | 解析为 | 当...时被拒绝 |
---|---|---|
Promise<[key: string]string> | 成功时,Promise 解析为存储在哈希中的字段及其值列表。 |
示例
import redis from 'k6/experimental/redis';
// Instantiate a new redis client
const redisClient = new redis.Client('redis://:6379');
export default async function () {
await redisClient.hset('myhash', 'myfield', 'myvalue');
await redisClient.hset('myhash', 'myotherfield', 'myothervalue');
const object = await redisClient.hgetall('myhash');
console.log(`myhash has key:value pairs ${JSON.stringify(object)}`);
}