comparison caching-tests/test.ur @ 2234:2f7ed04332a0

Progress on LRU cache but still more known bugs to fix.
author Ziv Scully <ziv@mit.edu>
date Sun, 28 Jun 2015 12:46:51 -0700
parents 6262dabc08d6
children 0aae15c2a05a
comparison
equal deleted inserted replaced
2233:af1585e7d645 2234:2f7ed04332a0
14 fun flush id = 14 fun flush id =
15 res <- oneOrNoRows (SELECT tab.Val 15 res <- oneOrNoRows (SELECT tab.Val
16 FROM tab 16 FROM tab
17 WHERE tab.Id = {[id]}); 17 WHERE tab.Id = {[id]});
18 (case res of 18 (case res of
19 None => dml (INSERT INTO tab (Id, Val) 19 None => return () (* dml (INSERT INTO tab (Id, Val) *)
20 VALUES ({[id]}, 0)) 20 (* VALUES ({[id]}, 0)) *)
21 | Some row => dml (UPDATE tab 21 | Some row => dml (UPDATE tab
22 SET Val = {[row.Tab.Val + 1]} 22 SET Val = {[row.Tab.Val + 1]}
23 WHERE Id = {[id]})); 23 WHERE Id = {[id + 1]} OR Id = {[id]} (* OR Id = {[id - 1]} *)));
24 return <xml><body> 24 return <xml><body>
25 {case res of 25 {case res of
26 None => <xml>Initialized {[id]}!</xml> 26 None => <xml>Initialized {[id]}!</xml>
27 | Some row => <xml>Incremented {[id]}!</xml>} 27 | Some row => <xml>Incremented {[id]}!</xml>}
28 </body></xml> 28 </body></xml>
29
30 (* task periodic 5 = *)
31 (* fn () => *)
32 (* t <- now; *)
33 (* let *)
34 (* val n = toSeconds t % 2 *)
35 (* in *)
36 (* dml (UPDATE tab *)
37 (* SET Val = 9001 *)
38 (* WHERE Id = {[n]} OR Id = {[n+1]}) *)
39 (* end *)