Question

I am wondering if there are java methods/objects that would be alternatives to cfquery, that both allow variable sanitation, and better caching methods.

I know that you can use information schema to get data types and char lengths, and then use that to validate data type & length of variables in a query.

But with everyone converting to using cfqueryparam for bind variables and variable sanitation, that also prevents using caching on a cfquery.

So I was hoping there was better ways or scripts to get more performance and scalability...

Personally, I think we need a new way or method of caching in cfquery. Because what we really want isn't to cache for x number of minutes, but to cache until the data changes, use fresh data, then cache back again, until the data changes again..

Instead for years, we've had to calculate how long we want to cache a cfquery in coldfusion, which doesn't give a lot of control or awareness of when the data was changed or not..

Does this make sense?

Was it helpful?

Solution

First, let's eliminate a misconception. On CF8+, you can cache queries that use cfqueryparam. I'm not really sure what you mean by "everyone converting," either, since using it has been widely considered a best practice for a while.

So, I think your question is actually moot. While you can cache queries manually (and I do this for other datatypes) cfqueryparam hasn't been a reason to do this in a while.

OTHER TIPS

If you are looking for an "alternative" method of accessing data, ORM (Object Relation Mapping) is the way to go. If you are using CF9, the Hibernate library (Java) is used under the hood to manage the access and caching of data.

CF7+ users can use the Transfer library which was built by Mark Mandel for ORM capabilities.

In addition to jarofclay's answer I'd like to note that Transfer ORM has built-in caching system (though coming version will allow to use some even better existing solutions), this is how it delivers better performance.

Any way, I'd better started with schema and queries optimization plus tried to use caching, it can be done on really different levels: from db queries up to the rendered content.

For example, new version of Railo supports some enterprise-level caching engines like ehCache.

IMO this is better way to solve your performance task than trying to mess with Java and queries. If I understand things correctly, they still will be running through the same datasources, maybe even with same underlying byte-code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top