Skip to content

Commit 769372a

Browse files
committed
fix: clean up __expire__ table if entry is expired
1 parent 4684f87 commit 769372a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/factory.js

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ export default function factory(localforage) {
3636

3737
async function get(bin, key, validate = true) {
3838
const isValid = validate && cacheBins[bin] ? await cacheBins[EXPIRE_BIN].getItem(getExpireKey(bin, key)) > Date.now() : true;
39+
if (!isValid) {
40+
await cacheBins[EXPIRE_BIN].removeItem(getExpireKey(bin, key));
41+
}
3942
return isValid ? await cacheBins[bin].getItem(key) : null; // localForage return null if item doesn't exist
4043
}
4144

0 commit comments

Comments
 (0)