Skip to content

Add eviction handler#8

Open
luzlab wants to merge 4 commits into
DylanPiercey:masterfrom
luzlab:master
Open

Add eviction handler#8
luzlab wants to merge 4 commits into
DylanPiercey:masterfrom
luzlab:master

Conversation

@luzlab

@luzlab luzlab commented Feb 10, 2020

Copy link
Copy Markdown

Added a method on to specify a callback that gets called when a key is expired.

@coveralls

coveralls commented Feb 10, 2020

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling 90fad51 on luzlab:master into 9a40d7c on DylanPiercey:master.

@milkcha

milkcha commented May 7, 2020

Copy link
Copy Markdown

@DylanPiercey
i think this is our last requirement for this awesome module

@luzlab

luzlab commented May 21, 2020

Copy link
Copy Markdown
Author

@DylanPiercey @milkcha I'm not certain about is whether we should call the handler before or after the item is evicted. Any thoughts?

@DylanPiercey

DylanPiercey commented May 21, 2020

Copy link
Copy Markdown
Owner

@luzlab the main concern I have with this is that we are creating an event listener instance for a single event. It seems a bit wasteful to me.

If it suites your use-case I think it'd be better just to have something like:

const cache = new Receptacle();

cache.onDelete = (key, value) => {
  console.log("deleted", key, "which was", value);
}

Or just having it as an option to receptacle, eg:

new Receptacle({
  onDelete(k, v){ /* ... */ }
})

Thoughts?

@milkcha

milkcha commented May 23, 2020

Copy link
Copy Markdown

i would like

new Receptacle({
  onDelete(k, v){ /* ... */ }
})

it keep the lib simple and excellent quick. no need an event system. if we need , we can dispatch then event to other event lib use onDelete.
and
I'm not certain about is whether we should call the handler before or after the item is evicted too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants