Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data


< > BotCompany Repo | #1005146 // getServerTranspiled2 - with (safe) caching. first line is libs

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (4667L) is out of date.

scope getServerTranspiled2.

please include function loadPage.

sbool #allowLocalFallback = true, #localFallbackVerbose = true;

// to avoid checking server for transpilations too often when booting OS
static SS getServerTranspiled2_tempCache;

sS getServerTranspiled2(S id) {
  ifndef NoResourceLoader
  IResourceLoader rl = vm_getResourceLoader();
  if (rl != null)
    ret rl.getTranspiled(id);
  ret getServerTranspiled2_noResourceLoader(id);
sS getServerTranspiled2_noResourceLoader(S id) {
  id = fsIOpt(id);
  S transpiled = mapGet(getServerTranspiled2_tempCache, id);
  if (transpiled != null) ret transpiled;
  //if (getServerTranspiled2_tempCache != null) print("CACHE FAIL on " + id);
  transpiled = loadCachedTranspilation(id);
  S md5 = null;
  if (machineIsOffline() || isOfflineMode() || isLocalSnippet(id)) ret transpiled;
  if (transpiled != null)
    md5 = md5(transpiled);
  S transpiledSrc;
  try {
    transpiledSrc = getServerTranspiled(formatSnippetID(id), md5);
  } catch e {
    if (!allowLocalFallback) rethrow(e);
    if (localFallbackVerbose) print("Fallback to local code");
    ret transpiled;
  if (eq(transpiledSrc, "SAME")) {
    if (!isTrue(loadPage_silent!)) printWithMS("SAME");
    ret mapPut_returnValue(getServerTranspiled2_tempCache, id, transpiled);
  ret mapPut_returnValue(getServerTranspiled2_tempCache, id, transpiledSrc);

end scope

download  show line numbers  debug dex  old transpilations   

Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, ekrmjmnbrukm, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1005146
Snippet name: getServerTranspiled2 - with (safe) caching. first line is libs
Eternal ID of this version: #1005146/18
Text MD5: 8a02c0659913b6c7b5874aac9017ba79
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-06 23:14:06
Source code size: 1489 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 761 / 1038
Version history: 17 change(s)
Referenced in: [show references]