Mini Program nodejs background timer how to write?

just work on the front-end rookie. All of a sudden, I want to write about Mini Program backstage. I have no idea at all.

demand:
front end:
user 8ju 00max 81max 01max 8rig 02. The click-by-click button server needs to return the data obtained from api at 8:05 to the user.
user 8: 15: 00; 8: 00; 8: 00; 16: 00; 8: 12: 17 The click-by-click button server needs to return the data obtained from api at 8:20 to the user.
(the rule is multiples of the next 5 minutes from the current time)

api data is updated every 5 minutes. A request at 8:04 can only get data at 8: 00:00.

background:
the nodejs deployed by Tencent Cloud with one click.
I think we should use timer with https.get.
ask for a train of thought. Thank you!

Apr.09,2021

the front end acquires data normally, so there is nothing to say.

every time the backend has a front-end query, if [this query has been separated by a 5-minute boundary from the cached result of the last query], then [get the latest data and cache it in the global variable]. If [this query has not been delimited and there is data in the cache, the cached data will be returned directly]

Menu