import redis from 'k6/experimental/redis';
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'),
password: redis_password,
});
export default function () {
redisClient
.hset('myhash', 'myfield', 'myvalue')
.then((_) => redisClient.hset('myhash', 'myotherfield', 'myothervalue'))
.then((_) => redisClient.hvals('myhash'))
.then((values) => {
if (values.length !== 2) {
throw new Error('myhash should have 2 values');
}
console.log(`myhash has values ${values}`);
});
}