diff options
Diffstat (limited to 'caching-tests')
-rw-r--r-- | caching-tests/test.ur | 36 | ||||
-rw-r--r-- | caching-tests/test.urp | 5 | ||||
-rw-r--r-- | caching-tests/test.urs | 2 |
3 files changed, 43 insertions, 0 deletions
diff --git a/caching-tests/test.ur b/caching-tests/test.ur new file mode 100644 index 00000000..f6568db4 --- /dev/null +++ b/caching-tests/test.ur @@ -0,0 +1,36 @@ +table tab : {Id : int, Val : int} PRIMARY KEY Id + +fun cache id = + res <- oneOrNoRows (SELECT tab.Val + FROM tab + WHERE tab.Id = {[id]}); + return <xml><body> + Reading {[id]}. + {case res of + None => <xml>?</xml> + | Some row => <xml>{[row.Tab.Val]}</xml>} + </body></xml> + +fun flush id = + dml (UPDATE tab + SET Val = Val * (Id + 2) / Val - 3 + WHERE Id = {[id]} OR Id = {[id - 1]} OR Id = {[id + 1]}); + return <xml><body> + Changed {[id]}! + </body></xml> + +(* fun flush id = *) +(* res <- oneOrNoRows (SELECT tab.Val *) +(* FROM tab *) +(* WHERE tab.Id = {[id]}); *) +(* (case res of *) +(* None => dml (INSERT INTO tab (Id, Val) *) +(* VALUES ({[id]}, 0)) *) +(* | Some row => dml (UPDATE tab *) +(* SET Val = {[row.Tab.Val + 1]} *) +(* WHERE Id = {[id]} OR Id = {[id + 1]})); *) +(* return <xml><body> *) +(* {case res of *) +(* None => <xml>Initialized {[id]}!</xml> *) +(* | Some row => <xml>Incremented {[id]}!</xml>} *) +(* </body></xml> *) diff --git a/caching-tests/test.urp b/caching-tests/test.urp new file mode 100644 index 00000000..796a6257 --- /dev/null +++ b/caching-tests/test.urp @@ -0,0 +1,5 @@ +database test.db +sql test.sql +safeGet Test/flush + +test diff --git a/caching-tests/test.urs b/caching-tests/test.urs new file mode 100644 index 00000000..6d4cedf2 --- /dev/null +++ b/caching-tests/test.urs @@ -0,0 +1,2 @@ +val cache : int -> transaction page +val flush : int -> transaction page |