Event Level Caching Bug or Aaron's Misunderstanding?

Hello ColdBox peeps!

Finishing up a redesign of my favorite video site and I enabled event level caching (finally, I’m able to take advantage of it on this site!!) and I was surprised to find SES variables are not respected when evaluating the cached event.

First, the tech details

Handler: episode.index
Route: /watch/:show_urlname/:urlname/:caption_language?
URL #1: /watch/maximizing-cs55-performance-with-intel-xeon-processors/maximizing-performance-with-intel-solid-state-drives/
URL #2: /watch/maximizing-cs55-performance-with-intel-xeon-processors/entrylevel-video-editing-performance-with-the-intel-xeon-e3-processor/
ColdBox: 3.5 Beta (just downloaded from Git)

It is my expectation that ColdBox would consider the RC variables declared within the route when creating the cache key for the event, however, this is not the case. Appending any random URL param busts the cache like one would expect, but, visiting two unique URLs with different values for the SES declared variables does not.

Did I set my expectations higher than I should have, or, is this a bug?

For my case, I’m already doing some onRequestCapture interceptor processing so I’ll just take the CGI.PATH_INFO value and copy it into the URL scope to fix this. But, I wanted to ask the community before sending a pull request since this could change the behavior of your sites.

Thanks,

Aaron

Actually, I’m thinking this is definitely a bug–but, it may be in our app.

Tracing the code, it looks like the routed structs are considered when building a portion of the cache key. "coldbox.system.cache.util.EventURLFacade.getUniqueHash() (line 48).

I’ll report back once I find it.

Thanks,

Aaron

OK! I’m not crazy…

I modified /coldbox/system/coldbox.cfc to write the cachekey to disk and a SHA hash of the cached content. You can see the modifications here: https://gist.github.com/1609535

Although ColdBox is using a unique cache-key, the same content is being returned and printed to the screen. Details below…

Request: 1
Page: 1
EventCacheKey: cbox_event-desktop.episode.index–3FCDC65D3B25310B01C0123C91866E11
Content Hash: 4EC2B64DAA41795A040ADA48AC77950B550E526E

Request: 2
Page: 1
EventCacheKey: cbox_event-desktop.episode.index–3FCDC65D3B25310B01C0123C91866E11

Content Hash: 4EC2B64DAA41795A040ADA48AC77950B550E526E

Request 3
Page: 2
EventCacheKey: cbox_event-desktop.episode.index–6CCE1A84EFCCB0B17EDFA29A3A436F28

Content Hash: 4EC2B64DAA41795A040ADA48AC77950B550E526E

Any advice from the ColdBox wizards?

Thanks,

Aaron

Is it too soon for April fools?

I’ve ruled out ColdBox now. Hope you guys can have a good laugh.

Yippie!

Aaron

Hmm I am pretty sure the routed struct is considered in the hash building the key

Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Social: twitter.com/ortussolutions | twitter.com/coldbox | twitter.com/lmajano

Lol! Let me know if you find anything or how we can improve it.

Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Social: twitter.com/ortussolutions | twitter.com/coldbox | twitter.com/lmajano

Darn, can’t even type write. I’m to am too tired to right using proper English.

A pues hablemos español Aaron. A si te das un break de solo escribir en ingles.

Saludos

Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Social: twitter.com/ortussolutions | twitter.com/coldbox | twitter.com/lmajano

SOLVED!

For anyone wondering what could have caused me to waste a few hours chasing this bug, read on!

Within a service I was using CacheBox to cache the raw data. But, when I created the cache key I failed to hash it.

// This was the bug
var cacheKey = arguments.toString();

// This is the fix
var cacheKey = hash(arguments.toString(),‘sha’);

I assume that only the first X characters were used to set/lookup the item in the cache either by CacheBox or ColdFusion9. It just happened that this page, the arguments are almost the same with the unique portion found near the end of the string.

Hope this helps someone.

Aaron

HA! That was not even it.

Even deeper, I was caching queries with CacheBox and I used the SQL to create the cache-key, but, failed to realize that the values were not in the SQL. They are all added as queryparams. DOE!

Enjoy your weekend peeps! It’s been a loooooong week for me :slight_smile:

LOL, Congrats!!!

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

No, wait-- this just in… GREMLINS actually caused it!! :slight_smile:

~Brad