MCPcopy Create free account
hub / github.com/PrairieLearn/PrairieLearn / getFromCacheOrRender

Function getFromCacheOrRender

question-servers/freeform.js:837–855  ·  view source on GitHub ↗
(cacheKey)

Source from the content-addressed store, hash-verified

835 // and either return the cached render for a cache hit, or render
836 // the panel for a cache miss
837 const getFromCacheOrRender = (cacheKey) => {
838 cache.get(cacheKey, (err, cachedData) => {
839 // We don't actually want to fail if the cache has an error; we'll
840 // just render the panel as normal
841 ERR(err, (e) => logger.error(e));
842 if (!err && cachedData !== null) {
843 const {
844 courseIssues,
845 html,
846 renderedElementNames,
847 } = cachedData;
848
849 const cacheHit = true;
850 callback(null, courseIssues, html, renderedElementNames, cacheHit);
851 } else {
852 doRender(cacheKey);
853 }
854 });
855 };
856
857 if (locals.devMode) {
858 // In dev mode, we should skip caching so that we'll immediately

Callers 1

freeform.jsFile · 0.85

Calls 2

callbackFunction · 0.85
doRenderFunction · 0.85

Tested by

no test coverage detected