Here's the problem we are trying to solve: Each time a product is updated, we want to dispatch a job that updates the search index. If several products were updated during a short period of time, we don't want to dispatch multiple jobs. There should be only a single index update job in the queue at any time. To solve this problem, we are going to use cache locks to prevent dispatching UpdateProductsIndex jobs while another instance of the job is in the queue.
With these simple changes, we made sure only a single UpdateProductsIndex job will be in the queue at any point in time.