Cache - activation

How to activate ?

Enabling cache on DataBaseDao

Let say we have a standard DataBaseDao<Pizza>, implemented IDao<Pizza> interface

public class DaoPizzaImpl extends AbstractDao<Pizza> implements IDaoPizza
public interface IDaoPizza extends IDao<Pizza>

To activate cache, just use AbstractCachedDao insteadof AbstractDao and extend interface with IDataBaseCached, which is also an extension od IDao

public class DaoPizzaImpl extends AbstractCachedDao<Pizza> implements IDaoPizza
public interface IDaoPizza extends IDatabaseCachedDao<Pizza>

Let's check it. 1000 loops and for pizza name:

ShowTime.compareCache(
	()->Select.fieldList(daoPizza.colName()).noCache().result(),
	()->Select.fieldList(daoPizza.colName()).result(),
	1000);

Result:

*********************************************************************************************
Compariation summary for 1000 loops: 
Non cached dao execution time: 00:00:00:988
Cached dao execution time: 00:00:00:18
*********************************************************************************************

Daobab cache speed up query execution to 5400%.