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)

static ExpiringMap2<S, S> loadSnippet_simpleCache_map = new ExpiringMap2(10000);
static Lock loadSnippet_simpleCache_lock = lock();

// timeout for loadPage
static int loadSnippet_simpleCache_timeout = 60000;

static S loadSnippet_simpleCache(S id) {
  if (id == null) null;
  lock loadSnippet_simpleCache_lock;
  id = fsI(id);
  
  // get from cache
  S src = loadSnippet_simpleCache_map.get(id);
  if (src != null) ret src;
  
  // load & put in cache
  Int oldTimeout = setThreadLocal(loadPage_forcedTimeout_byThread, loadSnippet_simpleCache_timeout);
  try {
    src = loadSnippet(id);
    if (src != null)
      loadSnippet_simpleCache_map.put(id, src);
    ret src;
  } finally {
    loadPage_forcedTimeout_byThread.set(oldTimeout);
  }
}

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: 591 / 606
Version history: 3 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1012213 - loadSnippet_simpleCache_setExpiration
#1015340 - loadSnippet_cached - synonym of loadSnippet_simpleCache