forked from GitHub/gf-core
gf -server: add a command to manually flush the PGF cache
This can be used if the cloud service seems slow, but it would probably be better to automatically expire unused PGFs from the cache after some time.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
module Cache (Cache,newCache,readCache) where
|
||||
module Cache (Cache,newCache,flushCache,readCache) where
|
||||
|
||||
import Control.Concurrent.MVar
|
||||
import Data.Map (Map)
|
||||
@@ -17,6 +17,9 @@ newCache load =
|
||||
do objs <- newMVar Map.empty
|
||||
return $ Cache { cacheLoad = load, cacheObjects = objs }
|
||||
|
||||
flushCache :: Cache a -> IO ()
|
||||
flushCache c = modifyMVar_ (cacheObjects c) (const (return Map.empty))
|
||||
|
||||
readCache :: Cache a -> FilePath -> IO a
|
||||
readCache c file =
|
||||
do v <- modifyMVar (cacheObjects c) findEntry
|
||||
|
||||
Reference in New Issue
Block a user