Play already comes with an easy to scale cache solution included, namely memcached. However, you might not want to use memcached at all. It might not fit your needs, your admin may not want to install another application on a system, or anything else. Instead of not using a cache at all, this recipe shows you how to write your own implementation of a cache. This example will use Hazelcast, a pure Java distributed system as implementation.
You can find the source code of this example in the examples/chapter6/caching-implementation
directory.
It requires a little bit of work to get to the point to start programming. We need to get Hazelcast instance up and running and setup an application for development. Hazelcast is basically a distributed data platform for the JVM. Hazelcast has tons of more features that are not needed in this little example—basically only a distributed map is featured here. Hazelcast scales very well, there are live examples...