Kaysoro / KaellyBot

Discord Bot for Dofus game
GNU General Public License v3.0
69 stars 26 forks source link

[perf] Cached API fetching for Almanax #262

Closed stelzo closed 3 years ago

stelzo commented 3 years ago

This PR increases performance by minimizing network traffic, adds some conveniences (item link and only relevant info) from the API data and avoids Ankama 404s. There are no added features since the last fallback stays the same as the current master.

New strategy:

if (cached) return cached
else if (apiData) returnAndCache apiData
else returnAndCache websiteData

Using Redis for caching. I included a docker-compose file just to make it easier for others to get started since the Almanax command now depends on Redis. Cached dates expire after 9 days to prevent wasting memory.