comparison caching-tests/test.ur @ 2273:a3cac6cea625

Consildation of caches understands sqlification.
author Ziv Scully <ziv@mit.edu>
date Wed, 04 Nov 2015 20:12:07 -0500
parents f7bc7c11a656
children ce96e166d938
comparison
equal deleted inserted replaced
2272:b49d22a4eda8 2273:a3cac6cea625
9 {case res of 9 {case res of
10 None => <xml>?</xml> 10 None => <xml>?</xml>
11 | Some row => <xml>{[row.Tab.Val]}</xml>} 11 | Some row => <xml>{[row.Tab.Val]}</xml>}
12 </body></xml> 12 </body></xml>
13 13
14 fun cache2 id v = 14 (* fun cache2 id v = *)
15 res <- oneOrNoRows (SELECT tab.Val 15 (* res <- oneOrNoRows (SELECT tab.Val *)
16 FROM tab 16 (* FROM tab *)
17 WHERE tab.Id = {[id]} AND tab.Val = {[v]}); 17 (* WHERE tab.Id = {[id]} AND tab.Val = {[v]}); *)
18 (* return <xml><body> *)
19 (* Reading {[id]}. *)
20 (* {case res of *)
21 (* None => <xml>Nope, that's not it.</xml> *)
22 (* | Some _ => <xml>Hooray! You guessed it!</xml>} *)
23 (* </body></xml> *)
24
25 fun cache2 id1 id2 =
26 res1 <- oneOrNoRows (SELECT tab.Val
27 FROM tab
28 WHERE tab.Id = {[id1]});
29 res2 <- oneOrNoRows (SELECT tab.Val
30 FROM tab
31 WHERE tab.Id = {[id2]});
18 return <xml><body> 32 return <xml><body>
19 Reading {[id]}. 33 Reading {[id1]} and {[id2]}.
20 {case res of 34 {case (res1, res2) of
21 None => <xml>Nope, that's not it.</xml> 35 (Some _, Some _) => <xml>Both are there.</xml>
22 | Some _ => <xml>Hooray! You guessed it!</xml>} 36 | _ => <xml>One of them is missing.</xml>}
23 </body></xml> 37 </body></xml>
24 38
25 fun flush id = 39 fun flush id =
26 dml (UPDATE tab 40 dml (UPDATE tab
27 SET Val = Val * (Id + 2) / Val - 3 41 SET Val = Val * (Id + 2) / Val - 3