Class GitHubClientCacheOps


  • public final class GitHubClientCacheOps
    extends Object
    Class with util functions to operate GitHub client cache
    Since:
    1.14.0
    Author:
    lanwen (Merkushev Kirill)
    • Method Detail

      • withEnabledCache

        public static com.google.common.base.Predicate<GitHubServerConfig> withEnabledCache()
        Returns:
        predicate which returns true if cache enabled for applied GitHubServerConfig
      • cacheToName

        public static com.google.common.base.Function<okhttp3.Cache,​String> cacheToName()
        Extracts relative to base cache dir name of cache folder for each config For example if the full path to cache folder is "$JENKINS_HOME/org.jenkinsci.plugins.github.GitHubPlugin.cache/keirurna", this function returns "keirurna"
        Returns:
        function to extract folder name from cache object
      • notInCaches

        public static DirectoryStream.Filter<Path> notInCaches​(Set<String> caches)
        To accept for cleaning only not active cache dirs
        Parameters:
        caches - set of active cache names, extracted with help of cacheToName()
        Returns:
        filter to accept only names not in set
      • getBaseCacheDir

        public static Path getBaseCacheDir()
        This directory contains all other cache dirs for each client config
        Returns:
        path to base cache directory.
      • clearRedundantCaches

        public static void clearRedundantCaches​(List<GitHubServerConfig> configs)
        Removes all not active dirs with old caches. This method is invoked after each save of global plugin config
        Parameters:
        configs - active server configs to exclude caches from cleanup