2 USING: kernel assocs locals combinators
3 math math.functions system unicode ;
7 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9 : nx-cache ( -- table ) H{ } ;
11 : nx-cache-at ( name -- time ) >lower nx-cache at ;
12 : nx-cache-delete-at ( name -- ) >lower nx-cache delete-at ;
13 : nx-cache-set-at ( time name -- ) >lower nx-cache set-at ;
15 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
17 : now ( -- seconds ) millis 1000.0 / round >integer ;
19 :: non-existent-name? ( NAME -- ? )
20 [let | TIME [ NAME nx-cache-at ] |
22 { [ TIME f = ] [ f ] }
23 { [ TIME now <= ] [ NAME nx-cache-delete-at f ] }
29 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
31 :: cache-non-existent-name ( NAME TTL -- )
32 [let | TIME [ TTL now + ] | TIME NAME nx-cache-set-at ] ;
34 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!