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

32
LINES

< > BotCompany Repo | #1006320 // SnippetTitles - cache for snippet titles

JavaX fragment (include)

1  
sclass SnippetTitles {
2  
  Map<Long, S> titles = synchroHashMap();
3  
  
4  
  S get(S snippetID) {
5  
    if (snippetID == null) null;
6  
    long id = parseSnippetID(snippetID);
7  
    if (titles.containsKey(id))
8  
      ret titles.get(id);
9  
    else {
10  
      S title = getSnippetTitle_safe(snippetID);
11  
      titles.put(id, title);
12  
      ret title;
13  
    }
14  
  }
15  
  
16  
  // like get, but only check the cache
17  
  S probe(S id) {
18  
    ret titles.get(parseSnippetID(id));
19  
  }
20  
  
21  
  // advanced uses
22  
  
23  
  void put(S id, S title) {
24  
    titles.put(parseSnippetID(id), title);
25  
  }
26  
  
27  
  bool has(S id) {
28  
    ret titles.containsKey(parseSnippetID(id));
29  
  }
30  
  
31  
  void clear() { titles.clear(); }
32  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006320
Snippet name: SnippetTitles - cache for snippet titles
Eternal ID of this version: #1006320/6
Text MD5: dc7068e73384edf50d14f5841bc17a67
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-11-07 01:34:40
Source code size: 688 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 601 / 1442
Version history: 5 change(s)
Referenced in: [show references]