TekkenChicken / chicken-server

Backend for Tekken Chicken app
2 stars 2 forks source link

Add lightweight caching via redis to server to reduce mysql calls #11

Open bdickason opened 7 years ago

bdickason commented 7 years ago

Mysql calls are synchronous, slow, and expensive. Since our app is just serving a big bundle of json data, I propose the following:

  1. Install redis: http://redis.io
  2. When express receives a cache-able route (framedata, metadata, characterdata), call redis first with the url as the list and the version as the key within that list.
  3. Redis should return the cached json blob in one response. If the json blob doesn't exist, it should call our controller to generate the response via mysql, pass it through, and then store it in redis.

This is super, super simple and stupid caching, but should give us alot of speed and efficiency games for very little work.

I suspect we could use express middleware for this if we wanted: https://www.npmjs.com/package/express-redis-cache