Ensure keys are removed
This commit is contained in:
parent
e228b9c207
commit
319b3afddb
|
@ -96,6 +96,10 @@ export class DocWritethrough {
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.db.put(doc)
|
await this.db.put(doc)
|
||||||
|
|
||||||
|
for (const key of keysToPersist) {
|
||||||
|
await cache.delete(key, { useTenancy: false })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -181,5 +181,33 @@ describe("docWritethrough", () => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("cached values are persisted only once", async () => {
|
||||||
|
await config.doInTenant(async () => {
|
||||||
|
const initialPatch = generatePatchObject(5)
|
||||||
|
|
||||||
|
await docWritethrough.patch(initialPatch)
|
||||||
|
travelForward(WRITE_RATE_MS)
|
||||||
|
|
||||||
|
await docWritethrough.patch({})
|
||||||
|
|
||||||
|
expect(await db.get(documentId)).toEqual(
|
||||||
|
expect.objectContaining(initialPatch)
|
||||||
|
)
|
||||||
|
|
||||||
|
await db.remove(await db.get(documentId))
|
||||||
|
|
||||||
|
travelForward(WRITE_RATE_MS)
|
||||||
|
const extraPatch = generatePatchObject(5)
|
||||||
|
await docWritethrough.patch(extraPatch)
|
||||||
|
|
||||||
|
expect(await db.get(documentId)).toEqual(
|
||||||
|
expect.objectContaining(extraPatch)
|
||||||
|
)
|
||||||
|
expect(await db.get(documentId)).not.toEqual(
|
||||||
|
expect.objectContaining(initialPatch)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue