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

26
LINES

< > BotCompany Repo | #1012210 // loadSnippet_simpleCache - expires in 10 seconds

JavaX fragment (include)

1  
static ExpiringMap2<S, S> loadSnippet_simpleCache_map = new ExpiringMap2(10000);
2  
static Lock loadSnippet_simpleCache_lock = lock();
3  
4  
// timeout for loadPage
5  
static int loadSnippet_simpleCache_timeout = 60000;
6  
7  
static S loadSnippet_simpleCache(S id) {
8  
  if (id == null) null;
9  
  lock loadSnippet_simpleCache_lock;
10  
  id = fsI(id);
11  
  
12  
  // get from cache
13  
  S src = loadSnippet_simpleCache_map.get(id);
14  
  if (src != null) ret src;
15  
  
16  
  // load & put in cache
17  
  Int oldTimeout = setThreadLocal(loadPage_forcedTimeout_byThread, loadSnippet_simpleCache_timeout);
18  
  try {
19  
    src = loadSnippet(id);
20  
    if (src != null)
21  
      loadSnippet_simpleCache_map.put(id, src);
22  
    ret src;
23  
  } finally {
24  
    loadPage_forcedTimeout_byThread.set(oldTimeout);
25  
  }
26  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1012210
Snippet name: loadSnippet_simpleCache - expires in 10 seconds
Eternal ID of this version: #1012210/4
Text MD5: 159848caf252034bbbb0f079c476c3b7
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-03 18:36:47
Source code size: 769 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 592 / 607
Version history: 3 change(s)
Referenced in: [show references]