comparison caching-tests/test.ur @ 2204:01c8aceac480

Finishes initial prototype, caching parameterless pages with table-match-based invalidation. Still has problems parsing non-Postgres SQL dialects properly.
author Ziv Scully <ziv@mit.edu>
date Tue, 27 May 2014 21:14:13 -0400
parents 39faa4a037f4
children 0ca11d57c175
comparison
equal deleted inserted replaced
2203:39faa4a037f4 2204:01c8aceac480
1 table foo01 : {Id : int, Bar : string} PRIMARY KEY Id 1 table foo01 : {Id : int, Bar : string} PRIMARY KEY Id
2 table foo10 : {Id : int, Bar : string} PRIMARY KEY Id 2 table foo10 : {Id : int, Bar : string} PRIMARY KEY Id
3 3
4 (* val query = (SELECT * FROM foo WHERE foo.Bar = "baz") *) 4 fun flush01 () : transaction page =
5 (* val insert = (INSERT INTO foo (Id, Bar) VALUES (42, "baz")) *) 5 dml (INSERT INTO foo01 (Id, Bar) VALUES (42, "baz01"));
6 dml (UPDATE foo01 SET Bar = "baz01" WHERE Id = 42);
7 return <xml><body>
8 Flushed 1!
9 </body></xml>
6 10
7 fun flush01 () : transaction page= 11 fun flush10 () : transaction page =
8 dml (INSERT INTO foo01 (Id, Bar) VALUES (42, "baz")); 12 dml (UPDATE foo10 SET Bar = "baz10" WHERE Id = 42);
9 return 13 return <xml><body>
10 <xml> 14 Flushed 2!
11 <body> 15 </body></xml>
12 Flushed 1!
13 </body>
14 </xml>
15 16
16 fun flush10 () : transaction page= 17 fun flush11 () : transaction page =
17 dml (INSERT INTO foo10 (Id, Bar) VALUES (42, "baz")); 18 dml (UPDATE foo01 SET Bar = "baz11" WHERE Id = 42);
18 return 19 dml (UPDATE foo10 SET Bar = "baz11" WHERE Id = 42);
19 <xml> 20 return <xml><body>
20 <body> 21 Flushed 1 and 2!
21 Flushed 2! 22 </body></xml>
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 23
35 fun cache01 () : transaction page = 24 fun cache01 () : transaction page =
36 res <- oneOrNoRows (SELECT foo01.Id, foo01.Bar 25 res <- oneOrNoRows (SELECT foo01.Bar FROM foo01 WHERE foo01.Id = 42);
37 FROM foo01 26 return <xml><body>
38 WHERE foo01.Bar = "baz"); 27 Reading 1.
39 return 28 {case res of
40 <xml> 29 None => <xml></xml>
41 <body> 30 | Some row => <xml>{[row.Foo01.Bar]}</xml>}
42 Reading 1. 31 </body></xml>
43 {case res of
44 None => <xml></xml>
45 | Some row => <xml>{[row.Foo01.Bar]}</xml>}
46 </body>
47 </xml>
48 32
49 fun cache10 () : transaction page = 33 fun cache10 () : transaction page =
50 res <- oneOrNoRows (SELECT foo10.Id, foo10.Bar 34 res <- oneOrNoRows (SELECT foo10.Bar FROM foo10 WHERE foo10.Id = 42);
51 FROM foo10 35 return <xml><body>
52 WHERE foo10.Bar = "baz"); 36 Reading 2.
53 return 37 {case res of
54 <xml> 38 None => <xml></xml>
55 <body> 39 | Some row => <xml>{[row.Foo10.Bar]}</xml>}
56 Reading 2. 40 </body></xml>
57 {case res of
58 None => <xml></xml>
59 | Some row => <xml>{[row.Foo10.Bar]}</xml>}
60 </body>
61 </xml>
62 41
63 fun cache11 () : transaction page = 42 fun cache11 () : transaction page =
64 res <- oneOrNoRows (SELECT foo01.Id, foo01.Bar 43 res <- oneOrNoRows (SELECT foo01.Bar FROM foo01 WHERE foo01.Id = 42);
65 FROM foo01 44 bla <- oneOrNoRows (SELECT foo10.Bar FROM foo10 WHERE foo10.Id = 42);
66 WHERE foo01.Bar = "baz"); 45 return <xml><body>
67 bla <- oneOrNoRows (SELECT foo10.Id, foo10.Bar 46 Reading 1 and 2.
68 FROM foo10 47 {case res of
69 WHERE foo10.Bar = "baz"); 48 None => <xml></xml>
70 return 49 | Some row => <xml>{[row.Foo01.Bar]}</xml>}
71 <xml> 50 {case bla of
72 <body> 51 None => <xml></xml>
73 Reading 1 and 2. 52 | Some row => <xml>{[row.Foo10.Bar]}</xml>}
74 {case res of 53 </body></xml>
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>