Mercurial > urweb
comparison caching-tests/test.ur @ 2221:278e10629ba1
Basic field-resolution invalidation.
author | Ziv Scully <ziv@mit.edu> |
---|---|
date | Sat, 29 Nov 2014 03:37:59 -0500 |
parents | f7113855f3b7 |
children | 6262dabc08d6 |
comparison
equal
deleted
inserted
replaced
2220:794017f378de | 2221:278e10629ba1 |
---|---|
9 {case res of | 9 {case res of |
10 None => <xml>?</xml> | 10 None => <xml>?</xml> |
11 | Some row => <xml>{[row.Foo01.Bar]}</xml>} | 11 | Some row => <xml>{[row.Foo01.Bar]}</xml>} |
12 </body></xml> | 12 </body></xml> |
13 | 13 |
14 fun cache10 () = | 14 (* fun cache10 () = *) |
15 res <- queryX (SELECT foo10.Bar FROM foo10 WHERE foo10.Id = 42) | 15 (* res <- queryX (SELECT foo10.Bar FROM foo10 WHERE foo10.Id = 42) *) |
16 (fn row => <xml>{[row.Foo10.Bar]}</xml>); | 16 (* (fn row => <xml>{[row.Foo10.Bar]}</xml>); *) |
17 return <xml><body> | 17 (* return <xml><body> *) |
18 Reading 2. | 18 (* Reading 2. *) |
19 {res} | 19 (* {res} *) |
20 </body></xml> | 20 (* </body></xml> *) |
21 | 21 |
22 fun cache11 () = | 22 (* fun cache11 () = *) |
23 res <- oneOrNoRows (SELECT foo01.Bar FROM foo01 WHERE foo01.Id = 42); | 23 (* res <- oneOrNoRows (SELECT foo01.Bar FROM foo01 WHERE foo01.Id = 42); *) |
24 bla <- oneOrNoRows (SELECT foo10.Bar FROM foo10 WHERE foo10.Id = 42); | 24 (* bla <- oneOrNoRows (SELECT foo10.Bar FROM foo10 WHERE foo10.Id = 42); *) |
25 return <xml><body> | 25 (* return <xml><body> *) |
26 Reading 1 and 2. | 26 (* Reading 1 and 2. *) |
27 {case res of | 27 (* {case res of *) |
28 None => <xml>?</xml> | 28 (* None => <xml>?</xml> *) |
29 | Some row => <xml>{[row.Foo01.Bar]}</xml>} | 29 (* | Some row => <xml>{[row.Foo01.Bar]}</xml>} *) |
30 {case bla of | 30 (* {case bla of *) |
31 None => <xml>?</xml> | 31 (* None => <xml>?</xml> *) |
32 | Some row => <xml>{[row.Foo10.Bar]}</xml>} | 32 (* | Some row => <xml>{[row.Foo10.Bar]}</xml>} *) |
33 </body></xml> | 33 (* </body></xml> *) |
34 | 34 |
35 fun flush01 () = | 35 fun flush01 () = |
36 dml (INSERT INTO foo01 (Id, Bar) VALUES (42, "baz01")); | 36 dml (INSERT INTO foo01 (Id, Bar) VALUES (42, "baz01")); |
37 (* dml (UPDATE foo01 SET Bar = "baz01" WHERE Id = 42); *) | 37 (* dml (UPDATE foo01 SET Bar = "baz01" WHERE Id = 42); *) |
38 return <xml><body> | 38 return <xml><body> |
39 Flushed 1! | 39 Flushed 1! |
40 </body></xml> | 40 </body></xml> |
41 | 41 |
42 fun flush10 () = | 42 (* fun flush10 () = *) |
43 dml (UPDATE foo10 SET Bar = "baz10" WHERE Id = 42); | 43 (* dml (UPDATE foo10 SET Bar = "baz10" WHERE Id = 42); *) |
44 return <xml><body> | 44 (* return <xml><body> *) |
45 Flushed 2! | 45 (* Flushed 2! *) |
46 </body></xml> | 46 (* </body></xml> *) |
47 | 47 |
48 fun flush11 () = | 48 (* fun flush11 () = *) |
49 dml (UPDATE foo01 SET Bar = "baz11" WHERE Id = 42); | 49 (* dml (UPDATE foo01 SET Bar = "baz11" WHERE Id = 42); *) |
50 dml (UPDATE foo10 SET Bar = "baz11" WHERE Id = 42); | 50 (* dml (UPDATE foo10 SET Bar = "baz11" WHERE Id = 42); *) |
51 return <xml><body> | 51 (* return <xml><body> *) |
52 Flushed 1 and 2! | 52 (* Flushed 1 and 2! *) |
53 </body></xml> | 53 (* </body></xml> *) |
54 | 54 |
55 fun cache id = | 55 fun cache id = |
56 res <- oneOrNoRows (SELECT tab.Val FROM tab WHERE tab.Id = {[id]}); | 56 res <- oneOrNoRows (SELECT tab.Val FROM tab WHERE tab.Id = {[id]}); |
57 return <xml><body> | 57 return <xml><body> |
58 Reading {[id]}. | 58 Reading {[id]}. |
61 | Some row => <xml>{[row.Tab.Val]}</xml>} | 61 | Some row => <xml>{[row.Tab.Val]}</xml>} |
62 </body></xml> | 62 </body></xml> |
63 | 63 |
64 fun flush id = | 64 fun flush id = |
65 res <- oneOrNoRows (SELECT tab.Val FROM tab WHERE tab.Id = {[id]}); | 65 res <- oneOrNoRows (SELECT tab.Val FROM tab WHERE tab.Id = {[id]}); |
66 dml (case res of | 66 (case res of |
67 None => (INSERT INTO tab (Id, Val) VALUES ({[id]}, 0)) | 67 None => dml (INSERT INTO tab (Id, Val) VALUES ({[id]}, 0)) |
68 | Some row => (UPDATE tab SET Val = {[row.Tab.Val + 1]} WHERE Id = {[id]})); | 68 | Some row => dml (UPDATE tab SET Val = {[row.Tab.Val + 1]} WHERE Id = {[id]})); |
69 return <xml><body> | 69 return <xml><body> |
70 (* Flushed {[id]}! *) | 70 (* Flushed {[id]}! *) |
71 {case res of | 71 {case res of |
72 None => <xml>Initialized {[id]}!</xml> | 72 None => <xml>Initialized {[id]}!</xml> |
73 | Some row => <xml>Incremented {[id]}!</xml>} | 73 | Some row => <xml>Incremented {[id]}!</xml>} |