From ca3efa1458583772a9826198ed4b99eec381f2de Mon Sep 17 00:00:00 2001 From: Ziv Scully Date: Wed, 6 May 2015 23:11:30 -0400 Subject: More work factoring out Sqlcache back end. --- src/sqlcache.sml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/sqlcache.sml') diff --git a/src/sqlcache.sml b/src/sqlcache.sml index 931c6737..3082904c 100644 --- a/src/sqlcache.sml +++ b/src/sqlcache.sml @@ -1,4 +1,4 @@ -structure Sqlcache (* :> SQLCACHE *) = struct +structure Sqlcache :> SQLCACHE = struct open Mono @@ -39,6 +39,10 @@ val ffiEffectful = andalso not (m = "Basis" andalso SS.member (fs, f)) end +val cache = ref ToyCache.cache +fun setCache c = cache := c +fun getCache () = !cache + (* Effect analysis. *) @@ -366,6 +370,8 @@ val tableDml = (* Program instrumentation. *) +val {check, store, flush, ...} = getCache () + val dummyLoc = ErrorMsg.dummySpan fun stringExp s = (EPrim (Prim.String (Prim.Normal, s)), dummyLoc) @@ -400,8 +406,8 @@ fun cacheWrap (query, i, urlifiedRel0, resultTyp, args) = (* We ensure before this step that all arguments aren't effectful. by turning them into local variables as needed. *) val argsInc = map (incRels 1) args - val check = (ToyCache.check (i, args), dummyLoc) - val store = (ToyCache.store (i, argsInc, urlifiedRel0), dummyLoc) + val check = (check (i, args), dummyLoc) + val store = (store (i, argsInc, urlifiedRel0), dummyLoc) val rel0 = (ERel 0, loc) in ECase (check, @@ -545,7 +551,7 @@ fun invalidations ((query, numArgs), dml) = fun addFlushing (file, (tableToIndices, indexToQueryNumArgs, _)) = let val flushes = List.concat o - map (fn (i, argss) => map (fn args => ToyCache.flush (i, args)) argss) + map (fn (i, argss) => map (fn args => flush (i, args)) argss) val doExp = fn EDml (origDmlText, failureMode) => let -- cgit v1.2.3