RE: [coldbox:13764] model inject model dependency and ocm

Sorry, but I’ve got to get back to an emergency project at work. I’m not sure what to tell you right now other than to try a different approach.

I never inject objects from the cache into my model. Instead, I like to just have the model ask the appropriate service for what it needs. The service abstracts the caching inside of itself like so:

function getThing

if cache.exists(‘thing’)
return cache.get(‘thing’);
var thing = generateThing();
return thing

Of course, you’ll want some named locks mixed in there if you’re concerned about multiple requests all hitting the else at the same time.



after adding this block to onrequeststart, i think it’s fixed although I am not 100% sure if this is the preferred way

var rc = event.getCollection(); if(not getColdboxOCM().lookup("DataCompany")){ getColdBoxOCM().set('DataCompany',getModel('Company').DataCompany(),0); } if(not getColdboxOCM().lookup("DataMall")){ getColdBoxOCM().set('DataMall',getModel('Mall').DataMall(),0); } if(not getColdboxOCM().lookup("DataStates")){ getColdBoxOCM().set('DataStates',getModel('Information').DataStates(),0); } if(not getColdboxOCM().lookup("DataUserLevels")){ getColdBoxOCM().set('DataUserLevels',getModel('Permissions').DataUserLevels(),0); } if(not getColdboxOCM().lookup("DataNav")){ getColdBoxOCM().set('DataNav',getModel('Menu').DataNav(),0); }

thanks for your help

Chris Hough