Mercurial > urweb
comparison src/lru_cache.sml @ 2286:0bdfec16a01d
Fix issue with one-element caches. Locking still WIP.
author | Ziv Scully <ziv@mit.edu> |
---|---|
date | Fri, 13 Nov 2015 01:04:32 -0500 |
parents | ad3ce1528f71 |
children | 98f96a976ede |
comparison
equal
deleted
inserted
replaced
2285:ad3ce1528f71 | 2286:0bdfec16a01d |
---|---|
21 fun store (index, keys, value) = | 21 fun store (index, keys, value) = |
22 ffiAppCache' ("store", index, (value, stringTyp) :: withTyp stringTyp keys) | 22 ffiAppCache' ("store", index, (value, stringTyp) :: withTyp stringTyp keys) |
23 | 23 |
24 fun flush (index, keys) = | 24 fun flush (index, keys) = |
25 ffiAppCache' ("flush", index, withTyp optionStringTyp keys) | 25 ffiAppCache' ("flush", index, withTyp optionStringTyp keys) |
26 | |
27 fun lock (index, write) = | |
28 ffiAppCache' ((if write then "w" else "r") ^ "lock", index, []) | |
26 | 29 |
27 | 30 |
28 (* Cjr *) | 31 (* Cjr *) |
29 | 32 |
30 open Print | 33 open Print |
155 if numKeys args = 0 | 158 if numKeys args = 0 |
156 then implToy args | 159 then implToy args |
157 else implLru args | 160 else implLru args |
158 | 161 |
159 val cache = | 162 val cache = |
160 let | 163 (* let *) |
161 val {check = toyCheck, | 164 (* val {check = toyCheck, *) |
162 store = toyStore, | 165 (* store = toyStore, *) |
163 flush = toyFlush, | 166 (* flush = toyFlush, *) |
164 setupQuery = toySetupQuery, | 167 (* setupQuery = toySetupQuery, *) |
165 ...} = ToyCache.cache | 168 (* ...} = ToyCache.cache *) |
166 in | 169 (* in *) |
167 {check = toyIfNoKeys (length o #2) check toyCheck, | 170 (* {check = toyIfNoKeys (length o #2) check toyCheck, *) |
168 store = toyIfNoKeys (length o #2) store toyStore, | 171 (* store = toyIfNoKeys (length o #2) store toyStore, *) |
169 flush = toyIfNoKeys (length o #2) flush toyFlush, | 172 (* flush = toyIfNoKeys (length o #2) flush toyFlush, *) |
170 setupQuery = toyIfNoKeys #params setupQuery toySetupQuery, | 173 {check = check, store = store, flush = flush, lock = lock, |
171 setupGlobal = setupGlobal} | 174 setupQuery = setupQuery, setupGlobal = setupGlobal} |
172 end | 175 (* end *) |
173 | 176 |
174 end | 177 end |