Setting up a caching system
A good example on how to do it is always the best way to learn a new technique quickly. That is why we will show you how to implement a caching system on different parts of our application.
Getting ready
In this recipe we will show off a simple system that makes use of caching. We will also show off some benchmarks so that we can clearly see the differences between a system without caching and a system with caching. The code for this project can also be found with the book, which contain a couple of sample classes so that we can measure the performance a bit better. We will not discuss any of the sample classes (which all can be found in the /module/Application/src/Application
directory), but we will refer to them in some of the examples.
How to do it…
Setting up a simple caching system is easy enough, but the question most of the time is, where to begin.
Benchmarking our application before cache
For the benchmark we will use an application called ab
, which is short...