DataMgr 2.5 Documentation: SmartCache


SmartCache is an experimental feature that allows for very simple data caching when using DataMgr on ColdFusion 8.

SmartCache is best in situations where all of the data changes to a database are happening through DataMgr (though it can work when other data changes are made from ColdFusion). It also makes sense in systems where data is retrieved far more frequently than it is updated.

To enable SmartCache, pass a SmartCache argument to the init() method with a value of true.

<cfset Application.DataMgr = CreateObject("component","DataMgr").init(datasource="MyDSN",SmartCache=true)>

Once SmartCache is enabled, DataMgr will track when data is changed in the database. If DataMgr is asked to run a query that it has already run since the last change to data, it will just get the query from cache instead. This will save a trip to the database and enable quicker execution.

If any data has changed since the last time the query has run, it will run the query again. This is done universally rather than by table since any query could reference multiple tables by use of relation fields or custom SQL.

Internally, DataMgr calls the setCacheDate() function any time that it performs an operation that could change data in the database. If you make any data changes outside of DataMgr, you can just call the setCacheDate() (no arguments needed) to tell DataMgr about the change.

This is still experimental, but for some systems has the potential to provide some real performance improvements.