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

13
LINES

< > BotCompany Repo | #1019886 // md5OfFile_cached

JavaX fragment (include)

static int md5OfFile_cached_interval = 10*60000; // forget after 10 minutes

static Map<File, Pair<Pair<Long>, S>> md5OfFile_cached_map = syncExpiringMap(md5OfFile_cached_interval); // pair(pair(lastModified, size), md5)

sS md5OfFile_cached(File f) {
  if (f == null) null;
  if (!f.exists()) ret md5OfFile(f);
  Pair<Pair<Long>, S> p = md5OfFile_cached_map.get(f);
  Pair<Long> modInfo = pair(lastModified(f), fileSize(f));
  if (!eq(pairA(p), modInfo))
    md5OfFile_cached_map.put(f, p = pair(modInfo, md5OfFile(f)));
  ret p.b;
}

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: 304 / 339
Version history: 3 change(s)
Referenced in: [show references]