[Other doc versions]
[Doc downloads (PDF, HTML, XML)]
If you've got CI or other automatic tooling set up to poll Stash for changes, you can end up with high load on your Stash server. Consider for instance a CI server that has a number of builds set up for a given repository. Each of those builds polls Stash for changes and when it detects a change, it starts a new build. If your CI server supports parallel and/or chained build steps, each of these builds typically results in multiple clone operations of the same repository. The result: lots of polling for changes, and bursts of clones of a repository.
CI results in highly repetitive calls to Stash: polling for changes typically results in the same response 90% of the time and a build triggers a number of identical clone calls to Stash. Both operations can benefit greatly from caching when you experience repetitive load from CI.
Stash 2.5, and later versions, ship with the SCM Cache Plugin already bundled. The plugin is enabled by default, but note that ref advertisement is disabled by default – see the 'Limitations' section below. The plugin is also available from the Atlassian Marketplace.
Cache data is stored on disk for both ref advertisements and for clone operations for a configurable period of time. Since large instances can potentially consume an entire disk the SCM Cache Plugin monitors remaining disk space and is automatically disabled when the configured minimum free disk space is reached.
See Stash config properties for descriptions of the available system properties.
Enable the SCM Cache Plugin from the admin area in Stash. Click Manage Add-ons (under 'Add-Ons') and filter for system add-ons. Click SCM Cache Plugin for Stash and then either Enable or Disable.
The SCM Cache Plugin for Stash can be configured using either the REST endpoint (some settings, not all) or the system properties in
<STASH-HOME>/stash-config.properties. Settings configured through REST are considered before the settings in
|Retrieve the protocols for which caching has been enabled.|
|Enable caching of hosting requests for the protocol (HTTP or SSH).|
|Disable caching of hosting requests for the protocol (HTTP or SSH).|
|Retrieve whether ref advertisement caching is enabled (true) or disabled (false).|
Enable (status = true) or disable (status = false) ref advertisement caching.
|Retrieve the expiry in seconds for the ref advertisement caches.|
|Set the expiry in seconds for the ref advertisement caches.|
|Retrieve whether clone caching is enabled (true) or disabled (false).|
|Enable (status = true) or disable (status = false) clone caching.|
|Retrieve the expiry in seconds for the clone caches.|
|Set the expiry in seconds for the clone caches.|
|Retrieve information about the current caches: size, number of cache hits and misses, etc.|
|Clear all caches.|
|Retrieve information about the caches for the repository identified by projectKey and repoSlug: size, number of cache hits and misses, etc.|
Clear the caches for the repository identified by projectKey and repoSlug.