Query cache

Query caching is not enabled by default. To use Query caching we need to explicitly enable it on the @Cache mapping annotation for the entity bean types we want to use it.

Enabling query cache

The example below enables query caching on the Customer entity bean.

public class Customer {


To use the query cache you have to explicitly specify its use on a query.

// use the query cache
List<Country> list = DB.find(Country.class)
  .where().ilike("name", "New%")

The query cache is generally useful for returning lists that are very infrequently changed. These lists would often be used to populate drop down lists / combo boxes in user interfaces.

If you are familiar with the term "Lookup Tables" or "Reference Tables" these are typical candidates for using cached queries. Some examples of lookup/reference tables could be, countries, currencies and order status.

Query cache lists are read only.


All query caching implementations (including Hazelcast and Apache Ignite) uses near caches and can be tuned using @CacheQueryTuning.

@CacheQueryTuning(maxSecsToLive = 30)
public class Product  {