Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current 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');
}
}