I see anorm is not a ORM framework, it is querying data directly by SQL. For most of the application/website, we should not query the database everytime, we needs to cache the data either by SQL or item id. I wonder whether playframework has provided any kind of caching mechanism? If not how to add it?
Thanks.
You can use the Play cache in your controller, before querying your database. Here is a straightforward example derived from the Play cache documentation and the Scala API:
In this code, before trying to query the database, we make a lookup in the cache to check if the User has not been loaded previously. If not found in the cache, we store it in the cache with an expiration in 10 seconds.