Skip to content

Commit

Permalink
fix(multi): wait deserialize promise
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Mar 28, 2022
1 parent 45b544c commit 898fcbe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions packages/multi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
},
"devDependencies": {
"@keyvhq/sqlite": "latest",
"@keyvhq/compress": "latest",
"ava": "latest",
"delay": "latest"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/multi/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MultiCache {
const key = this.remote._getKeyPrefix(...args)

const raw = await this.remote.store.get(key)
const data = typeof raw === 'string' ? this.remote.deserialize(raw) : raw
const data = typeof raw === 'string' ? await this.remote.deserialize(raw) : raw

const hasValue = data ? data.value !== undefined : false
const isFresh =
Expand Down
19 changes: 10 additions & 9 deletions packages/multi/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
const test = require('ava')
const delay = require('delay')

const KeyvMulti = require('..')
const Keyv = require('@keyvhq/core')
const keyvCompress = require('@keyvhq/compress')
const KeyvSqlite = require('@keyvhq/sqlite')
const Keyv = require('@keyvhq/core')
const KeyvMulti = require('..')

const remoteStore = () =>
new Keyv({
store: new KeyvSqlite({
uri: 'sqlite://test/testdb.sqlite',
busyTimeout: 30000
})
const remoteStore = () => keyvCompress(new Keyv({
store: new KeyvSqlite({
uri: 'sqlite://test/testdb.sqlite',
busyTimeout: 30000
})
const localStore = () => new Keyv()
}))

const localStore = () => keyvCompress(new Keyv())

test.beforeEach(async () => {
const remote = remoteStore()
Expand Down

0 comments on commit 898fcbe

Please sign in to comment.