Mercurial > urweb
annotate 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 |
rev | line source |
---|---|
ziv@2203 | 1 table foo01 : {Id : int, Bar : string} PRIMARY KEY Id |
ziv@2203 | 2 table foo10 : {Id : int, Bar : string} PRIMARY KEY Id |
ziv@2203 | 3 |
ziv@2204 | 4 fun flush01 () : transaction page = |
ziv@2204 | 5 dml (INSERT INTO foo01 (Id, Bar) VALUES (42, "baz01")); |
ziv@2204 | 6 dml (UPDATE foo01 SET Bar = "baz01" WHERE Id = 42); |
ziv@2204 | 7 return <xml><body> |
ziv@2204 | 8 Flushed 1! |
ziv@2204 | 9 </body></xml> |
ziv@2203 | 10 |
ziv@2204 | 11 fun flush10 () : transaction page = |
ziv@2204 | 12 dml (UPDATE foo10 SET Bar = "baz10" WHERE Id = 42); |
ziv@2204 | 13 return <xml><body> |
ziv@2204 | 14 Flushed 2! |
ziv@2204 | 15 </body></xml> |
ziv@2203 | 16 |
ziv@2204 | 17 fun flush11 () : transaction page = |
ziv@2204 | 18 dml (UPDATE foo01 SET Bar = "baz11" WHERE Id = 42); |
ziv@2204 | 19 dml (UPDATE foo10 SET Bar = "baz11" WHERE Id = 42); |
ziv@2204 | 20 return <xml><body> |
ziv@2204 | 21 Flushed 1 and 2! |
ziv@2204 | 22 </body></xml> |
ziv@2203 | 23 |
ziv@2203 | 24 fun cache01 () : transaction page = |
ziv@2204 | 25 res <- oneOrNoRows (SELECT foo01.Bar FROM foo01 WHERE foo01.Id = 42); |
ziv@2204 | 26 return <xml><body> |
ziv@2204 | 27 Reading 1. |
ziv@2204 | 28 {case res of |
ziv@2204 | 29 None => <xml></xml> |
ziv@2204 | 30 | Some row => <xml>{[row.Foo01.Bar]}</xml>} |
ziv@2204 | 31 </body></xml> |
ziv@2203 | 32 |
ziv@2203 | 33 fun cache10 () : transaction page = |
ziv@2204 | 34 res <- oneOrNoRows (SELECT foo10.Bar FROM foo10 WHERE foo10.Id = 42); |
ziv@2204 | 35 return <xml><body> |
ziv@2204 | 36 Reading 2. |
ziv@2204 | 37 {case res of |
ziv@2204 | 38 None => <xml></xml> |
ziv@2204 | 39 | Some row => <xml>{[row.Foo10.Bar]}</xml>} |
ziv@2204 | 40 </body></xml> |
ziv@2203 | 41 |
ziv@2203 | 42 fun cache11 () : transaction page = |
ziv@2204 | 43 res <- oneOrNoRows (SELECT foo01.Bar FROM foo01 WHERE foo01.Id = 42); |
ziv@2204 | 44 bla <- oneOrNoRows (SELECT foo10.Bar FROM foo10 WHERE foo10.Id = 42); |
ziv@2204 | 45 return <xml><body> |
ziv@2204 | 46 Reading 1 and 2. |
ziv@2204 | 47 {case res of |
ziv@2204 | 48 None => <xml></xml> |
ziv@2204 | 49 | Some row => <xml>{[row.Foo01.Bar]}</xml>} |
ziv@2204 | 50 {case bla of |
ziv@2204 | 51 None => <xml></xml> |
ziv@2204 | 52 | Some row => <xml>{[row.Foo10.Bar]}</xml>} |
ziv@2204 | 53 </body></xml> |