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

17
LINES

< > BotCompany Repo | #1019166 // ExpiringValue (don't persist)

JavaX fragment (include)

sclass ExpiringValue<A> {
  A value;
  long expires; // in sysNow() time
  
  *() {}
  *(A *value, long expiryTime) { expires = sysNow()+expiryTime; }
  
  A get() { 
    checkExpiry();
    ret value;
  }
  
  void checkExpiry {
    if (sysNow() > expires)
      value = null;
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1019166
Snippet name: ExpiringValue (don't persist)
Eternal ID of this version: #1019166/1
Text MD5: 5813358c1c562e6ce5484d65b57b5548
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-26 15:15:23
Source code size: 298 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 364 / 898
Referenced in: [show references]