'Redis wait for key to be cached in GET request

I have two REST end-points

  1. POST request, this request does some long running task and fills the key-value pair in the cache.
  2. GET request this gets the data from the cache corresponding to a particular key.

Now sometimes Spring-boot server gets the GET request even before the post request has finished processing, so I want some way such that the GET request waits for the key to get cached in the server. If within 1-second the key does not get cached null is returned from the GET end point.

Can anyone please help me with some solution or a way to solve this problem.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source