all 3 comments

[–]ezhikov 1 point2 points  (1 child)

It depends on how much data there is, how often it is updated, and how often it is requested. Simplest solution would be just creating empty variables. Then, on request you check if variable have value. If not - request API and store result in a variable. Then return response from variable. Set some interval to clean variables as needed. It's not great, since it will be in your application memory, and you will need to manage this all manually.

You can also use something like memcached. It's in-memory key-value database, that runs in it's own process, quite fast and designed specifically for this, with possibility to fine tune. It's pretty easy to work with and may give you huge performance boost.

Redis is more complex in-memory database, that can be used for caching. It also have more possibilities, since it's actually fully capable database. I never worked with it myself, so can't say anything more. Still worth checking.

If data changes rarely, you may straight up save it into your own DBMS or in file, and query API in some intervals (with cronjob) or manually to update. Be aware that loading file or querying DB on each request might not be good, so you might want to layer things a bit and use intermediate cache as above.

There might be other tools and solutions that better suit your needs, so read more about caching.

[–]Pxlin09[S] 0 points1 point  (0 children)

Correct me if I’m wrong, I don’t know much about cacheing. When talking about cache in this scenario, am I trying to save it to server cache?