Interface GlobalCacheManager
-
- All Known Implementing Classes:
DefaultGlobalCacheManager
public interface GlobalCacheManagerManages global cache which users should never know. Typically, global cache exists in ~/.gradle/go with following structure:
+ ~/.gradle/go
|
|-- cache stores global go repository cache, e.g., golang.org/x/tools.
| \-- golang.org/x/tools
| |-- metadata
| \-- (1a2b3c4d5e6f7890)
\-- binary stores go distributions. The metadata also acts as a lock in synchronization of multiple JVM process.
-
-
Method Summary
All Methods Instance Methods Abstract 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.
-
-
-
Method Detail
-
ensureGlobalCacheExistAndWritable
void ensureGlobalCacheExistAndWritable()
Ensures global cache exists and is writable.
-
startSession
void startSession(VcsGolangPackage pkg)
Starts a session with given package.- Parameters:
pkg- e.g. golang.org/x/tools
-
endSession
void endSession()
Terminates current session (in the same thread).
-
repoUpdated
void repoUpdated()
Notifies that the repository in current session has been updated.
-
currentRepositoryIsUpToDate
boolean currentRepositoryIsUpToDate()
Check if the repository in current session has been updated recently.- Returns:
trueif the package is up-to-date,falseotherwise.- See Also:
GolangPluginSetting.getGlobalCacheSecond()
-
getGlobalCacheRepoDir
java.io.File getGlobalCacheRepoDir()
Get the go repository in global cache in current session- Returns:
- the location of that repository in global cache
-
getGlobalGoBinCacheDir
java.io.File getGlobalGoBinCacheDir(java.lang.String relativePath)
Get the path which locates inrelativePathrelative to ~/.gradle/go/binary- Parameters:
relativePath- the relative path to ~/.gradle/go/binary- Returns:
- the path
-
getMetadata
java.util.Optional<GlobalCacheMetadata> getMetadata(java.nio.file.Path packagePath)
Get the metadata of a package specified bypackagePath- Parameters:
packagePath- import path of the package- Returns:
- the metadata if that package exists in global cache,
Optional.empty()otherwise.
-
-