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’);
else
var thing = generateThing();
cache.set(‘thing’,thing);
return thing
/if
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.