Client.hget(key, field)
返回存储在键为 key
的哈希中与 field
关联的值。
参数
参数 | 类型 | 描述 |
---|---|---|
key | string | 持有要获取字段的哈希的键。 |
field | string | 要从哈希中获取的字段。 |
返回值
类型 | 成功解析时返回 | 拒绝时 |
---|---|---|
Promise<string> | 成功时,Promise 解析为与 field 关联的值。 | 如果哈希不存在,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.hget('myhash', 'myfield');
await redisClient.hdel('myhash', 'myfield');
}