Class DefaultGlobalCacheManager
- java.lang.Object
-
- com.github.blindpirate.gogradle.core.cache.DefaultGlobalCacheManager
-
- All Implemented Interfaces:
GlobalCacheManager
@Singleton public class DefaultGlobalCacheManager extends java.lang.Object implements GlobalCacheManager
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringGO_BINARAY_CACHE_PATHstatic java.lang.StringREPO_CACHE_PATH
-
Constructor Summary
Constructors Constructor Description DefaultGlobalCacheManager(GolangPluginSetting setting)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancurrentRepositoryIsUpToDate()Check if the repository in current session has been updated recently.voidendSession()Terminates current session (in the same thread).voidensureGlobalCacheExistAndWritable()Ensures global cache exists and is writable.java.io.FilegetGlobalCacheRepoDir()Get the go repository in global cache in current sessionjava.io.FilegetGlobalGoBinCacheDir(java.lang.String relativePath)Get the path which locates inrelativePathrelative to ~/.gradle/go/binaryjava.util.Optional<GlobalCacheMetadata>getMetadata(java.nio.file.Path packagePath)Get the metadata of a package specified bypackagePathvoidrepoUpdated()Notifies that the repository in current session has been updated.voidstartSession(VcsGolangPackage pkg)Starts a session with given package.
-
-
-
Field Detail
-
REPO_CACHE_PATH
public static final java.lang.String REPO_CACHE_PATH
- See Also:
- Constant Field Values
-
GO_BINARAY_CACHE_PATH
public static final java.lang.String GO_BINARAY_CACHE_PATH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultGlobalCacheManager
@Inject public DefaultGlobalCacheManager(GolangPluginSetting setting)
-
-
Method Detail
-
ensureGlobalCacheExistAndWritable
public void ensureGlobalCacheExistAndWritable()
Description copied from interface:GlobalCacheManagerEnsures global cache exists and is writable.- Specified by:
ensureGlobalCacheExistAndWritablein interfaceGlobalCacheManager
-
startSession
public void startSession(VcsGolangPackage pkg)
Description copied from interface:GlobalCacheManagerStarts a session with given package.- Specified by:
startSessionin interfaceGlobalCacheManager- Parameters:
pkg- e.g. golang.org/x/tools
-
endSession
public void endSession()
Description copied from interface:GlobalCacheManagerTerminates current session (in the same thread).- Specified by:
endSessionin interfaceGlobalCacheManager
-
repoUpdated
public void repoUpdated()
Description copied from interface:GlobalCacheManagerNotifies that the repository in current session has been updated.- Specified by:
repoUpdatedin interfaceGlobalCacheManager
-
getGlobalCacheRepoDir
public java.io.File getGlobalCacheRepoDir()
Description copied from interface:GlobalCacheManagerGet the go repository in global cache in current session- Specified by:
getGlobalCacheRepoDirin interfaceGlobalCacheManager- Returns:
- the location of that repository in global cache
-
getGlobalGoBinCacheDir
public java.io.File getGlobalGoBinCacheDir(java.lang.String relativePath)
Description copied from interface:GlobalCacheManagerGet the path which locates inrelativePathrelative to ~/.gradle/go/binary- Specified by:
getGlobalGoBinCacheDirin interfaceGlobalCacheManager- Parameters:
relativePath- the relative path to ~/.gradle/go/binary- Returns:
- the path
-
getMetadata
public java.util.Optional<GlobalCacheMetadata> getMetadata(java.nio.file.Path packagePath)
Description copied from interface:GlobalCacheManagerGet the metadata of a package specified bypackagePath- Specified by:
getMetadatain interfaceGlobalCacheManager- Parameters:
packagePath- import path of the package- Returns:
- the metadata if that package exists in global cache,
Optional.empty()otherwise.
-
currentRepositoryIsUpToDate
public boolean currentRepositoryIsUpToDate()
Description copied from interface:GlobalCacheManagerCheck if the repository in current session has been updated recently.- Specified by:
currentRepositoryIsUpToDatein interfaceGlobalCacheManager- Returns:
trueif the package is up-to-date,falseotherwise.- See Also:
GolangPluginSetting.getGlobalCacheSecond()
-
-