Mercurial > urweb
comparison src/sql_cache.sml @ 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 |
comparison
equal
deleted
inserted
replaced
2203:39faa4a037f4 | 2204:01c8aceac480 |
---|---|
7 structure IM = IntBinaryMap | 7 structure IM = IntBinaryMap |
8 structure StringKey = struct type ord_key = string val compare = String.compare end | 8 structure StringKey = struct type ord_key = string val compare = String.compare end |
9 structure SS = BinarySetFn (StringKey) | 9 structure SS = BinarySetFn (StringKey) |
10 structure SM = BinaryMapFn (StringKey) | 10 structure SM = BinaryMapFn (StringKey) |
11 structure SIMM = MultimapFn (structure KeyMap = SM structure ValSet = IS) | 11 structure SIMM = MultimapFn (structure KeyMap = SM structure ValSet = IS) |
12 | |
13 val ffiIndices : int list ref = ref [] | |
14 val rs : int list ref = ref [] | |
15 val ws : int list ref = ref [] | |
12 | 16 |
13 val rec tablesRead = | 17 val rec tablesRead = |
14 fn Query1 {From=tablePairs, ...} => SS.fromList (map #1 tablePairs) | 18 fn Query1 {From=tablePairs, ...} => SS.fromList (map #1 tablePairs) |
15 | Union (q1,q2) => SS.union (tablesRead q1, tablesRead q2) | 19 | Union (q1,q2) => SS.union (tablesRead q1, tablesRead q2) |
16 | 20 |
52 con = if b then "True" else "False"}, | 56 con = if b then "True" else "False"}, |
53 NONE), | 57 NONE), |
54 loc) | 58 loc) |
55 fun boolTyp loc = (TFfi ("Basis", "int"), loc) | 59 fun boolTyp loc = (TFfi ("Basis", "int"), loc) |
56 | 60 |
57 fun ffiAppExp (module, func, arg, loc) = | 61 fun ffiAppExp (module, func, index, loc) = |
58 (EFfiApp (module, func, [(intExp (arg, loc), intTyp loc)]), loc) | 62 (EFfiApp (module, func ^ Int.toString index, []), loc) |
59 | 63 |
60 fun sequence (befores, center, afters, loc) = | 64 fun sequence (befores, center, afters, loc) = |
61 List.foldr (fn (exp, seq) => (ESeq (exp, seq), loc)) | 65 List.foldr (fn (exp, seq) => (ESeq (exp, seq), loc)) |
62 (List.foldl (fn (exp, seq) => (ESeq (seq, exp), loc)) | 66 (List.foldl (fn (exp, seq) => (ESeq (seq, exp), loc)) |
63 center | 67 center |
171 fun go file = | 175 fun go file = |
172 let | 176 let |
173 val {readers, writers} = handlerIndices file | 177 val {readers, writers} = handlerIndices file |
174 val (fileWithChecks, tablesToIndices) = addCacheChecking (file, readers) | 178 val (fileWithChecks, tablesToIndices) = addCacheChecking (file, readers) |
175 in | 179 in |
180 rs := IS.listItems readers; | |
181 ws := IS.listItems writers; | |
182 ffiIndices := IS.listItems readers; | |
176 addCacheFlushing (fileWithChecks, tablesToIndices, writers) | 183 addCacheFlushing (fileWithChecks, tablesToIndices, writers) |
177 end | 184 end |
178 | 185 |
179 end | 186 end |