Interface GlobalCacheManager

  • All Known Implementing Classes:
    DefaultGlobalCacheManager

    public interface GlobalCacheManager
    Manages 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 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:
        true if the package is up-to-date, false otherwise.
        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 in relativePath relative 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 by packagePath
        Parameters:
        packagePath - import path of the package
        Returns:
        the metadata if that package exists in global cache, Optional.empty() otherwise.