add a small cache of the most recently accessed item from the git-annex branch

This will speed up typical cases like git-annex get, which currently
has to read the location log once, then read it a second time in order to
add a line to it. Since these reads now involve more than just reading
in a file, it seemed good to add a cache layer.

Only the most recent thing needs to be cached, because git-annex has
good locality; it operates on one file at a time, and only cares
about one item from the branch per file.
This commit is contained in:
Joey Hess 2011-06-22 14:18:49 -04:00
parent 1cca8b4edb
commit 78a325b093
3 changed files with 38 additions and 6 deletions

View file

@ -23,6 +23,7 @@ import GitQueue
import Types.Backend
import Types.Remote
import Types.Crypto
import Types.Branch
import TrustLevel
import Types.UUID
@ -39,7 +40,8 @@ data AnnexState = AnnexState
, quiet :: Bool
, force :: Bool
, fast :: Bool
, updated :: Bool
, branchupdated :: Bool
, branchcache :: BranchCache
, forcebackend :: Maybe String
, forcenumcopies :: Maybe Int
, defaultkey :: Maybe String
@ -60,7 +62,8 @@ newState allbackends gitrepo = AnnexState
, quiet = False
, force = False
, fast = False
, updated = False
, branchupdated = False
, branchcache = emptyBranchCache
, forcebackend = Nothing
, forcenumcopies = Nothing
, defaultkey = Nothing