Debounced jobs
#43946
Replies: 2 comments 2 replies
-
I think this effect is achievable by using a combination of
Granted it would be much nicer if this could be extracted away with a simple |
Beta Was this translation helpful? Give feedback.
2 replies
-
I created a simple solution using job middleware that resolves this issue. It may require customization based on your needs, but this version has worked for me. https://gist.github.com/davutkmbr/43d442a39e2735274687cecdb70c2e74 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I had to implement a feature where a notification is sent out to the owner of the resource when the resource was commented on. The owner recieved an email for every comment. With a of burst activity (people replying to each other in quick succession) this would mean a lot of emails. This had to be debounced (every time someone replies restart the delay again).
I was bit suprised this wasn't already built in so I came up with the following solution.
This requires the database driver for the queue (but probably can be implemented with redis too)
$resource->getCacheKey()
is just a helper returning$this->getTable() . '.' . $this->getKey()
I could maybe make a PR for this but don't wanna spend the time before knowing it won't be in vain.
Beta Was this translation helpful? Give feedback.
All reactions