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

13
LINES

< > BotCompany Repo | #1019886 // md5OfFile_cached

JavaX fragment (include)

1  
static int md5OfFile_cached_interval = 10*60000; // forget after 10 minutes
2  
3  
static Map<File, Pair<Pair<Long>, S>> md5OfFile_cached_map = syncExpiringMap(md5OfFile_cached_interval); // pair(pair(lastModified, size), md5)
4  
5  
sS md5OfFile_cached(File f) {
6  
  if (f == null) null;
7  
  if (!f.exists()) ret md5OfFile(f);
8  
  Pair<Pair<Long>, S> p = md5OfFile_cached_map.get(f);
9  
  Pair<Long> modInfo = pair(lastModified(f), fileSize(f));
10  
  if (!eq(pairA(p), modInfo))
11  
    md5OfFile_cached_map.put(f, p = pair(modInfo, md5OfFile(f)));
12  
  ret p.b;
13  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 9 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1019886
Snippet name: md5OfFile_cached
Eternal ID of this version: #1019886/4
Text MD5: 0c316ec1a25dcf11f21f6cb9fad25507
Author: stefan
Category: javax / profiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-11-30 18:59:57
Source code size: 546 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 305 / 340
Version history: 3 change(s)
Referenced in: [show references]