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

48
LINES

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

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

Transpiled version (4667L) is out of date.

1  
scope getServerTranspiled2.
2  
3  
please include function loadPage.
4  
5  
sbool #allowLocalFallback = true, #localFallbackVerbose = true;
6  
7  
// to avoid checking server for transpilations too often when booting OS
8  
static SS getServerTranspiled2_tempCache;
9  
10  
sS getServerTranspiled2(S id) {
11  
  ifndef NoResourceLoader
12  
  IResourceLoader rl = vm_getResourceLoader();
13  
  if (rl != null)
14  
    ret rl.getTranspiled(id);
15  
  endifndef
16  
  
17  
  ret getServerTranspiled2_noResourceLoader(id);
18  
}
19  
  
20  
sS getServerTranspiled2_noResourceLoader(S id) {
21  
  id = fsIOpt(id);
22  
  
23  
  S transpiled = mapGet(getServerTranspiled2_tempCache, id);
24  
  if (transpiled != null) ret transpiled;
25  
  //if (getServerTranspiled2_tempCache != null) print("CACHE FAIL on " + id);
26  
  
27  
  transpiled = loadCachedTranspilation(id);
28  
  S md5 = null;
29  
  if (machineIsOffline() || isOfflineMode() || isLocalSnippet(id)) ret transpiled;
30  
  if (transpiled != null)
31  
    md5 = md5(transpiled);
32  
  S transpiledSrc;
33  
  try {
34  
    transpiledSrc = getServerTranspiled(formatSnippetID(id), md5);
35  
  } catch e {
36  
    if (!allowLocalFallback) rethrow(e);
37  
    printExceptionShort(e);
38  
    if (localFallbackVerbose) print("Fallback to local code");
39  
    ret transpiled;
40  
  }
41  
  if (eq(transpiledSrc, "SAME")) {
42  
    if (!isTrue(loadPage_silent!)) printWithMS("SAME");
43  
    ret mapPut_returnValue(getServerTranspiled2_tempCache, id, transpiled);
44  
  }
45  
  ret mapPut_returnValue(getServerTranspiled2_tempCache, id, transpiledSrc);
46  
}
47  
48  
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: 807 / 1094
Version history: 17 change(s)
Referenced in: [show references]