I am working on an application that requires an autocomplete field in the search form. CFML app on Railo 3.3. I use jQuery UI autocomplete and implemented a server side search as follows:
private struct function getStationDetails(required numeric uic) { var qryCacheStations = new query(); var qryStations = new query(); var cacheData = ""; var resultData = ""; var stcResult = {}; qryCacheStations.setDatasource(variables.instance['dataSource']); qryCacheStations.setSQL("select distinct uic, name, crs from stations order by name"); qryCacheStations.setCachedwithin(createTimeSpan(1,0,0,0)); cacheData = qryCacheStations.execute().getResult(); qryStations.setDBType("query"); qryStations.setAttributes(srcTbl = cacheData); qryStations.setSQL("select name, crs from srcTbl where uic = :uic"); qryStations.addParam(name="uic",value=arguments.uic,CFSQLType="CF_SQL_INTEGER"); resultData = qryStations.execute().getResult(); stcResult = { name = resultData['name'][1], crs = resultData['crs'][1] } return stcResult; }
Basically, I load the entire list of stations in the cache on the first search, after 1 day (data rarely changes), and then, using a query request, return the corresponding results to the client.
My question is simple; Is aggressive caching and QoQs a good picture? The performance seems good and the memory size is reasonable (the data set is quite small), so it โfeelsโ everything is in order, but am I looking for any advice from those who may have tried this before and found problems?
Any thoughts would be greatly appreciated.
source share