diff options
| author | hallgren <hallgren@chalmers.se> | 2014-04-09 17:51:25 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2014-04-09 17:51:25 +0000 |
| commit | d1da0e06de1d50e5246ea362ea8f2949b6a2a950 (patch) | |
| tree | f671f96bc52939b38eca57ed7299f2c0dbb1a60c /src/server/Cache.hs | |
| parent | 50ea3d265c35b677b60aa6a465eb19bcd66d25ad (diff) | |
PGF web service: add unlexers and enable client side caching
Most PGF web API commands that produce linearizations now accept an
unlexer parameter. Possible values are "text", "code" and "mixed".
The web service now include Date and Last-Modified headers in the HTTP,
responses. This means that browsers can treat responses as static content and
cache them, so it becomes less critical to cache parse results in the server.
Also did some cleanup in PGFService.hs, e.g. removed a couple of functions
that can now be imported from PGF.Lexing instead.
Diffstat (limited to 'src/server/Cache.hs')
| -rw-r--r-- | src/server/Cache.hs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/server/Cache.hs b/src/server/Cache.hs index 8cb9135e2..d7c806783 100644 --- a/src/server/Cache.hs +++ b/src/server/Cache.hs @@ -1,4 +1,4 @@ -module Cache (Cache,newCache,flushCache,readCache) where +module Cache (Cache,newCache,flushCache,readCache,readCache') where import Control.Concurrent.MVar import Data.Map (Map) @@ -21,7 +21,10 @@ flushCache :: Cache a -> IO () flushCache c = modifyMVar_ (cacheObjects c) (const (return Map.empty)) readCache :: Cache a -> FilePath -> IO a -readCache c file = +readCache c file = snd `fmap` readCache' c file + +readCache' :: Cache a -> FilePath -> IO (UTCTime,a) +readCache' c file = do v <- modifyMVar (cacheObjects c) findEntry modifyMVar v readObject where @@ -35,4 +38,4 @@ readCache c file = x' <- case m of Just (t,x) | t' == t -> return x _ -> cacheLoad c file - return (Just (t',x'), x') + return (Just (t',x'), (t',x')) |
