Skip to content

Commit

Permalink
fix: add "getdel" method
Browse files Browse the repository at this point in the history
Fixes: #46
  • Loading branch information
Harminder Virk authored and Harminder Virk committed Aug 13, 2022
1 parent 1028aaf commit b477850
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ioMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const ioMethods = [
'bitcount',
'bitfield',
'get',
'getdel',
'getBuffer',
'set',
'setBuffer',
Expand Down
27 changes: 27 additions & 0 deletions test/redis.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,31 @@ test.group('Redis Manager', () => {
await redis.del('greeting')
await redis.quit()
})

test('get and delete the key', async ({ assert }) => {
const app = new Application(__dirname, 'web', {})
const redis = new RedisManager(
app,
{
connection: 'primary',
connections: {
primary: {
host: process.env.REDIS_HOST,
port: Number(process.env.REDIS_PORT),
},
cluster: {
clusters: clusterNodes,
},
},
},
new Emitter(app)
) as unknown as RedisManagerContract

await redis.set('greeting', 'hello-world')

assert.equal(await redis.getdel('greeting'), 'hello-world')
assert.isUndefined(await redis.get('greeting'))

await redis.quit('primary')
})
})

0 comments on commit b477850

Please sign in to comment.