function getValue(key) { return cache[key]; } //returns true if the cached value is valid function isCached(key) { var val = getValue(key); //dirty = invalidated; null = nonexisting (but actively cached as such) return val != undefined && (val == null || val.isDirty !== true); }