This is documentation for the next version of K6. For the latest stable release, go to the latest version.
Client.getDel(key)
Get the value of key
and delete the key. This functionality is similar to get
, except for the fact that it also deletes the key on success.
Parameters
Returns
Example
import redis from 'k6/experimental/redis';
// Instantiate a new redis client
const redisClient = new redis.Client('redis://localhost:6379');
export default async function () {
await redisClient.set('mykey', 'oldvalue', 0);
let value = await redisClient.getSet('mykey', 'newvalue');
value = await redisClient.getDel('mykey');
if (value !== 'newvalue') {
throw new Error('mykey should have been newvalue');
}
}