;run: test that demonstrates caching
This commit is contained in:
parent
a0cf410a80
commit
a3d2c7bb58
@ -229,14 +229,13 @@ withJournalCached defaultJournalOverride cliopts cmd = do
|
|||||||
-- it separately.
|
-- it separately.
|
||||||
readAndCacheJournalFile :: InputOpts -> PrefixedFilePath -> IO Journal
|
readAndCacheJournalFile :: InputOpts -> PrefixedFilePath -> IO Journal
|
||||||
readAndCacheJournalFile iopts fp = do
|
readAndCacheJournalFile iopts fp = do
|
||||||
dbg1IO "readAndCacheJournalFile" fp
|
|
||||||
modifyMVar journalCache $ \cache ->
|
modifyMVar journalCache $ \cache ->
|
||||||
case Map.lookup (ioptsWithoutReportSpan,fp) cache of
|
case Map.lookup (ioptsWithoutReportSpan,fp) cache of
|
||||||
Just journal -> do
|
Just journal -> do
|
||||||
dbg1IO "readAndCacheJournalFile using cache" (fp, iopts)
|
dbg1IO ("readAndCacheJournalFile using cache for "++fp) iopts
|
||||||
return (cache, journal)
|
return (cache, journal)
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
dbg1IO "readAndCacheJournalFile reading and caching journals" (fp, iopts)
|
dbg1IO ("readAndCacheJournalFile reading and caching "++fp) iopts
|
||||||
journal <- runExceptT $ if snd (splitReaderPrefix fp) == "-" then readStdin else readJournalFile iopts fp
|
journal <- runExceptT $ if snd (splitReaderPrefix fp) == "-" then readStdin else readJournalFile iopts fp
|
||||||
either error' (\j -> return (Map.insert (ioptsWithoutReportSpan,fp) j cache, j)) journal
|
either error' (\j -> return (Map.insert (ioptsWithoutReportSpan,fp) j cache, j)) journal
|
||||||
where
|
where
|
||||||
|
|||||||
@ -149,3 +149,18 @@ Assets, depth 2:
|
|||||||
$-2 assets:cash
|
$-2 assets:cash
|
||||||
--------------------
|
--------------------
|
||||||
$-1
|
$-1
|
||||||
|
|
||||||
|
# ** 0. Run caches input files, and re-parses files when InputOptions change
|
||||||
|
<
|
||||||
|
2017-01-01 groceries
|
||||||
|
assets:cash -$100
|
||||||
|
expenses:food
|
||||||
|
$ hledger run --debug 1 -f- -- accounts -- balance -f sample.journal -- balance cash --forecast -- balance cash -f sample.journal --forecast -- register -- register -f sample.journal 2>&1 | grep readAndCacheJournalFile | sed -e "s#$(pwd)/##"
|
||||||
|
>
|
||||||
|
readAndCacheJournalFile reading and caching -:
|
||||||
|
readAndCacheJournalFile using cache for -:
|
||||||
|
readAndCacheJournalFile reading and caching sample.journal:
|
||||||
|
readAndCacheJournalFile reading and caching -:
|
||||||
|
readAndCacheJournalFile reading and caching sample.journal:
|
||||||
|
readAndCacheJournalFile using cache for -:
|
||||||
|
readAndCacheJournalFile using cache for sample.journal:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user