Skip to content

Commit

Permalink
fix(storage): clear cached keys
Browse files Browse the repository at this point in the history
  • Loading branch information
njfamirm committed Nov 2, 2022
1 parent 330858e commit fa2c4be
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/core/storage/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class AlwatrStorage<DocumentType extends DocumentObject> {
this._logger.logMethodArgs('set', documentObject._id);

const oldData = this._storage[documentObject._id];
if (oldData == null) this._keys = null; // Clear cached keys on new docId
if (oldData == null) this._keys = null; // Clear cached keys

if (fastInstance !== true) {
documentObject = JSON.parse(JSON.stringify(documentObject));
Expand Down Expand Up @@ -199,6 +199,10 @@ export class AlwatrStorage<DocumentType extends DocumentObject> {
}
// else
delete this._storage[documentId];

// Clear cached keys
this._keys = null;

this.save();
return true;
}
Expand Down Expand Up @@ -267,5 +271,8 @@ export class AlwatrStorage<DocumentType extends DocumentObject> {
this.forceSave();
}
this._storage = {};

// Clear cached keys
this._keys = null;
}
}

0 comments on commit fa2c4be

Please sign in to comment.