public class RepositoryCache extends Object
Repository
instances.Modifier and Type | Class and Description |
---|---|
static class |
RepositoryCache.FileKey
Location of a Repository, using the standard java.io.File API.
|
static interface |
RepositoryCache.Key
Abstract hash key for
RepositoryCache entries. |
Modifier and Type | Method and Description |
---|---|
static void |
clear()
Unregister all repositories from the cache.
|
static void |
close(Repository db)
Remove a repository from the cache.
|
static Collection<RepositoryCache.Key> |
getRegisteredKeys() |
static Repository |
open(RepositoryCache.Key location)
Open an existing repository, reusing a cached instance if possible.
|
static Repository |
open(RepositoryCache.Key location,
boolean mustExist)
Open a repository, reusing a cached instance if possible.
|
static void |
register(Repository db)
Register one repository into the cache.
|
static void |
unregister(RepositoryCache.Key location)
Remove a repository from the cache.
|
public static Repository open(RepositoryCache.Key location) throws IOException, RepositoryNotFoundException
When done with the repository, the caller must call
Repository.close()
to decrement the repository's usage counter.
location
- where the local repository is. Typically a RepositoryCache.FileKey
.IOException
- the repository could not be read (likely its core.version
property is not supported).RepositoryNotFoundException
- there is no repository at the given location.public static Repository open(RepositoryCache.Key location, boolean mustExist) throws IOException
When done with the repository, the caller must call
Repository.close()
to decrement the repository's usage counter.
location
- where the local repository is. Typically a RepositoryCache.FileKey
.mustExist
- If true, and the repository is not found, throws RepositoryNotFoundException
. If false, a repository instance
is created and registered anyway.IOException
- the repository could not be read (likely its core.version
property is not supported).RepositoryNotFoundException
- There is no repository at the given location, only thrown if
mustExist
is true.public static void register(Repository db)
During registration the cache automatically increments the usage counter,
permitting it to retain the reference. A RepositoryCache.FileKey
for the
repository's Repository.getDirectory()
is used to index the
repository in the cache.
If another repository already is registered in the cache at this location, the other instance is closed.
db
- repository to register.public static void close(Repository db)
Removes a repository from the cache, if it is still registered here, permitting it to close.
db
- repository to unregister.public static void unregister(RepositoryCache.Key location)
Removes a repository from the cache, if it is still registered here, permitting it to close.
location
- location of the repository to remove.public static Collection<RepositoryCache.Key> getRegisteredKeys()
public static void clear()
Copyright © 2015 Eclipse JGit Project. All rights reserved.