comparison caching-tests/test.ur @ 2203:39faa4a037f4

ML half of initial prototype. (Doesn't compile because there's no C yet.)
author Ziv Scully <ziv@mit.edu>
date Tue, 25 Mar 2014 02:04:06 -0400
parents
children 01c8aceac480
comparison
equal deleted inserted replaced
2202:606af2c9b828 2203:39faa4a037f4
1 table foo01 : {Id : int, Bar : string} PRIMARY KEY Id
2 table foo10 : {Id : int, Bar : string} PRIMARY KEY Id
3
4 (* val query = (SELECT * FROM foo WHERE foo.Bar = "baz") *)
5 (* val insert = (INSERT INTO foo (Id, Bar) VALUES (42, "baz")) *)
6
7 fun flush01 () : transaction page=
8 dml (INSERT INTO foo01 (Id, Bar) VALUES (42, "baz"));
9 return
10 <xml>
11 <body>
12 Flushed 1!
13 </body>
14 </xml>
15
16 fun flush10 () : transaction page=
17 dml (INSERT INTO foo10 (Id, Bar) VALUES (42, "baz"));
18 return
19 <xml>
20 <body>
21 Flushed 2!
22 </body>
23 </xml>
24
25 fun flush11 () : transaction page=
26 dml (INSERT INTO foo01 (Id, Bar) VALUES (42, "baz"));
27 dml (INSERT INTO foo10 (Id, Bar) VALUES (42, "baz"));
28 return
29 <xml>
30 <body>
31 Flushed 1 and 2!
32 </body>
33 </xml>
34
35 fun cache01 () : transaction page =
36 res <- oneOrNoRows (SELECT foo01.Id, foo01.Bar
37 FROM foo01
38 WHERE foo01.Bar = "baz");
39 return
40 <xml>
41 <body>
42 Reading 1.
43 {case res of
44 None => <xml></xml>
45 | Some row => <xml>{[row.Foo01.Bar]}</xml>}
46 </body>
47 </xml>
48
49 fun cache10 () : transaction page =
50 res <- oneOrNoRows (SELECT foo10.Id, foo10.Bar
51 FROM foo10
52 WHERE foo10.Bar = "baz");
53 return
54 <xml>
55 <body>
56 Reading 2.
57 {case res of
58 None => <xml></xml>
59 | Some row => <xml>{[row.Foo10.Bar]}</xml>}
60 </body>
61 </xml>
62
63 fun cache11 () : transaction page =
64 res <- oneOrNoRows (SELECT foo01.Id, foo01.Bar
65 FROM foo01
66 WHERE foo01.Bar = "baz");
67 bla <- oneOrNoRows (SELECT foo10.Id, foo10.Bar
68 FROM foo10
69 WHERE foo10.Bar = "baz");
70 return
71 <xml>
72 <body>
73 Reading 1 and 2.
74 {case res of
75 None => <xml></xml>
76 | Some row => <xml>{[row.Foo01.Bar]}</xml>}
77 {case bla of
78 None => <xml></xml>
79 | Some row => <xml>{[row.Foo10.Bar]}</xml>}
80 </body>
81 </xml>