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
.set('mykey', 'myvalue', 10)
.then((_) => redisClient.expire('mykey', 100))
.then((_) => redisClient.ttl('mykey'))
.then((ttl) => {
if (ttl <= 10) {
throw new Error('mykey should have a ttl of 10 <= x < 100');
}
return redisClient.persist('mykey', 100);
});
}