Class GitHubClientCacheOps
- java.lang.Object
-
- org.jenkinsci.plugins.github.internal.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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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"static void
clearRedundantCaches(List<GitHubServerConfig> configs)
Removes all not active dirs with old caches.static Path
getBaseCacheDir()
This directory contains all other cache dirs for each client configstatic DirectoryStream.Filter<Path>
notInCaches(Set<String> caches)
To accept for cleaning only not active cache dirsstatic com.google.common.base.Function<GitHubServerConfig,okhttp3.Cache>
toCacheDir()
static com.google.common.base.Predicate<GitHubServerConfig>
withEnabledCache()
-
-
-
Method Detail
-
withEnabledCache
public static com.google.common.base.Predicate<GitHubServerConfig> withEnabledCache()
- Returns:
- predicate which returns true if cache enabled for applied
GitHubServerConfig
-
toCacheDir
public static com.google.common.base.Function<GitHubServerConfig,okhttp3.Cache> toCacheDir()
- Returns:
- function to convert
GitHubServerConfig
toCache
-
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 ofcacheToName()
- 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
-
-