O'Reilly logo

Full Stack Web Development with Raspberry Pi 3 by Soham Kamani

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Caching our results

Our next problem is that we do not want to actually call our sensor interface every time someone requests the temperature and humidity through our API. To solve this, we need to cache our results.

In simple terms, this means that we need a temporary form of storage for the latest results. Whenever we receive a request, we will return results from this temporary storage, and not call the native sensor interface. In the background, we will periodically (the same period as the sensor) obtain readings from the sensor and update the cache.

Caching our results also provides us with other benefits:

  • Our server becomes much faster since the results are obtained directly from local memory rather than having to be read from the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required