aboutsummaryrefslogtreecommitdiffstats
path: root/app/History/Cache.hs
diff options
context:
space:
mode:
Diffstat (limited to 'app/History/Cache.hs')
-rw-r--r--app/History/Cache.hs33
1 files changed, 0 insertions, 33 deletions
diff --git a/app/History/Cache.hs b/app/History/Cache.hs
deleted file mode 100644
index 978f3d9..0000000
--- a/app/History/Cache.hs
+++ /dev/null
@@ -1,33 +0,0 @@
-module History.Cache
- ( cached,
- cachedMaybe,
- )
-where
-
-import Data.Binary (Binary, decodeFileOrFail, encodeFile)
-import Data.Text qualified as T
-import Debug
-import Git qualified
-import System.Directory (createDirectoryIfMissing, doesFileExist)
-import System.FilePath ((</>))
-
-cached :: Binary a => T.Text -> IO a -> IO a
-cached key func = do
- root <- Git.getRootDir
- createDirectoryIfMissing True (root </> ".anissue")
- let file = (root </> ".anissue" </> T.unpack key)
- doesFileExist file >>= \case
- True ->
- decodeFileOrFail file >>= \case
- Left e -> debug "e" e `seq` generate file
- Right blob -> pure blob
- False -> generate file
- where
- generate file = do
- blob <- func
- encodeFile (debug "cache miss" file) blob
- pure blob
-
-cachedMaybe :: Binary a => Maybe T.Text -> IO a -> IO a
-cachedMaybe Nothing func = func
-cachedMaybe (Just key) func = cached key func