summaryrefslogtreecommitdiff
path: root/lib/version_check.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-09-19 18:10:34 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-09-19 18:10:34 +0000
commit9134da04883fb17a8636cddbd457210fa8f5ab38 (patch)
tree54bc4be56906752103f9054d8b52a2ca6620a878 /lib/version_check.rb
parent8cfe3415e91f4403ded9cc44066a0a459688a609 (diff)
downloadgitlab-ce-9134da04883fb17a8636cddbd457210fa8f5ab38.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/version_check.rb')
-rw-r--r--lib/version_check.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/version_check.rb b/lib/version_check.rb
index 2d132001f54..35014f3ddf0 100644
--- a/lib/version_check.rb
+++ b/lib/version_check.rb
@@ -5,6 +5,36 @@ require "base64"
class VersionCheck
include ReactiveCaching
+ ## Version Check Reactive Caching
+ ## This cache stores the external API response from https://version.gitlab.com
+ ##
+ ## Example API Response
+ ## {
+ ## "latest_version": "15.2.2",
+ ## "severity": "success"
+ ## }
+ ##
+ ## This response from this endpoint only changes in 2 scenarios:
+ ## 1. Customer upgrades their GitLab Instance
+ ## 2. GitLab releases a new version
+ ##
+ ## We use GitLab::VERSION as the identifier for the cached information.
+ ## This means if the user upgrades their version we will create a new cache record.
+ ## The old one will be invalidated and cleaned up at the end of the self.reactive_cache_lifetime.
+ ##
+ ## - self.reactive_cache_refresh_interval = 12.hours
+ ## We want to prevent as many external API calls as possible to save on resources.
+ ## Since an EXISTING cache record will only become "invalid" if GitLab releases a new version we
+ ## determined that 12 hour intervals is enough of a window to capture an available upgrade.
+ ##
+ ## - self.reactive_cache_lifetime = 7.days
+ ## We don't want the data to be missing every time a user revisits a page using this info.
+ ## Thus 7 days seems like a fair amount of time before we erase the cache.
+ ## This also will handle cleaning up old cache records as they will no longer be accessed after an upgrade.
+ ##
+
+ self.reactive_cache_refresh_interval = 12.hours
+ self.reactive_cache_lifetime = 7.days
self.reactive_cache_work_type = :external_dependency
self.reactive_cache_worker_finder = ->(_id, *args) { from_cache }