Skip to content

Commit

Permalink
fix(liveslots): cache.delete() does not return a useful value
Browse files Browse the repository at this point in the history
Liveslots uses an internal `Cache` utility to hold data about virtual
objects, backed by the vatstore. PR #8752 included a change to make
its `delete()` method return a "did exist" boolean, just like a
JavaScript `Map`. Unfortunately the cache does not know whether a key
is present/absent in the backing store, so `delete()` will return an
erroneous value. It would cost an extra DB query to make this behave
as expected, and liveslots does not have a need for it.

So this commit reverts that change, and makes `delete()` return void
as before.
  • Loading branch information
warner committed Jun 14, 2024
1 parent 30e56ae commit 42ea8a3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/swingset-liveslots/src/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { Fail } from '@agoric/assert';
/**
* @callback CacheDelete
* @param {string} key
* @returns {boolean}
* @returns {void}
*
* @callback CacheFlush
* @returns {void}
Expand Down Expand Up @@ -83,9 +83,8 @@ export function makeCache(readBacking, writeBacking, deleteBacking) {
},
delete: key => {
assert.typeof(key, 'string');
const result = stash.delete(key);
stash.delete(key);
dirtyKeys.add(key);
return result;
},
flush: () => {
const keys = [...dirtyKeys.keys()];
Expand Down

0 comments on commit 42ea8a3

Please sign in to comment.