Query caching to run jQuery autocomplete

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.

+6
source share
2 answers

you can use jquery completion

cacheLength: number

to establish the ability to cache on the client side, so the number of calls on the server can be reduced, and performance can be improved.

+1
source

I have used this exact method with great success.

You are definitely doing the right thing in the belief that your data is not growing unexpectedly.

0
source

Source: https://habr.com/ru/post/896981/


All Articles