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)

sclass SnippetTitles {
  Map<Long, S> titles = synchroHashMap();
  
  S get(S snippetID) {
    if (snippetID == null) null;
    long id = parseSnippetID(snippetID);
    if (titles.containsKey(id))
      ret titles.get(id);
    else {
      S title = getSnippetTitle_safe(snippetID);
      titles.put(id, title);
      ret title;
    }
  }
  
  // like get, but only check the cache
  S probe(S id) {
    ret titles.get(parseSnippetID(id));
  }
  
  // advanced uses
  
  void put(S id, S title) {
    titles.put(parseSnippetID(id), title);
  }
  
  bool has(S id) {
    ret titles.containsKey(parseSnippetID(id));
  }
  
  void clear() { titles.clear(); }
}

download  show line numbers  debug dex   

Travelled to 11 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, tslmcundralx, tvejysmllsmz

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: 412 / 1009
Version history: 5 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1006320 & http://1006320.tinybrain.de