I am trying to create Repository with L2 cache with minimal setting. My database is postgresql.
I start with spring-boot-sample-data-jpa-archetype project using maven. I have removed the HSQL and create a DataSource bean to connect to postgresql. Also use ddl to create schema and imported the initial script data.
I have also added the @Cacheable to my entities. Then I use unit test to query an entity 10 times using repository. It took 1~49ms. So that leaves me two questions.
- Does repository benefits from L1 cache? how do I know if I am hitting the cache or data source?
- How to enable L2 cache? does Spring data has its own implementation?