1 | sbool loadSnippets_verbose; |
2 | |
3 | static L<S> loadSnippets(S... ids) { |
4 | ret loadSnippets(asList(ids)); |
5 | } |
6 | |
7 | static L<S> loadSnippets(L<S> ids) ctex { |
8 | new L<S> texts; |
9 | |
10 | new StringBuilder buf; |
11 | new Map<Long, S> cached; |
12 | initSnippetCache(); |
13 | for (S id : ids) { |
14 | long snippetID = psI(id); |
15 | S text = DiskSnippetCache_get(snippetID); |
16 | S md5 = text != null ? md5(text) : "."; |
17 | if (loadSnippets_verbose) |
18 | print(id + " => " + md5 + " - " + quote(shorten(text, 20))); |
19 | mapPut(cached, snippetID, text); |
20 | buf.append(snippetID).append(" ").append(md5).append(" "); |
21 | } |
22 | if (loadSnippets_verbose) |
23 | print("loadSnippets post data: " + buf); |
24 | |
25 | Map<S, O> map = jsonDecodeMap(doPost( |
26 | "ids=" + urlencode(trim(str(buf))) + standardCredentials(), |
27 | tb_mainServer() + "/get-multi2.php")); |
28 | |
29 | for (S id : ids) { |
30 | long snippetID = psI(id); |
31 | O result = map.get(str(snippetID)); |
32 | if (loadSnippets_verbose) |
33 | print(id + " => " + className(result)); |
34 | if (result instanceof S) { |
35 | texts.add((S) result); |
36 | DiskSnippetCache_put(snippetID, (S) result); |
37 | } else |
38 | texts.add(cached.get(snippetID)); |
39 | } |
40 | ret texts; |
41 | } |
Began life as a copy of #1003764
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1003875 |
Snippet name: | loadSnippets v2 - fetch multiple snippets in one go - yes it uses POST (LIVE) |
Eternal ID of this version: | #1003875/13 |
Text MD5: | ca49ea691c1e7e769de14329f39f434f |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-03-19 23:47:10 |
Source code size: | 1196 bytes / 41 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 677 / 1377 |
Version history: | 12 change(s) |
Referenced in: | [show references] |