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

13
LINES

< > BotCompany Repo | #1019888 // md5OfFile_throughString_cached

JavaX fragment (include)

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

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

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

Author comment

Began life as a copy of #1019886

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: #1019888
Snippet name: md5OfFile_throughString_cached
Eternal ID of this version: #1019888/1
Text MD5: 3b1e234209f2ef0df91d91194b60c8d1
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 19:02:34
Source code size: 658 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 284 / 317
Referenced in: [show references]