diff options
| author | Robert Speicher <robert@gitlab.com> | 2016-10-07 08:52:26 +0000 |
|---|---|---|
| committer | Robert Speicher <robert@gitlab.com> | 2016-10-07 08:52:26 +0000 |
| commit | a17412f0aa9ef9c99a5c136906ea8a585326c27d (patch) | |
| tree | 4e0d7171e0e9d6f57e151341d8b57328e4376ad1 /lib/tasks | |
| parent | c2cf1dd6c771ee3a181fa9704da593daa825c58a (diff) | |
| parent | 110e15da260f96baffb48bebb8cba796374fbb1e (diff) | |
| download | gitlab-ce-a17412f0aa9ef9c99a5c136906ea8a585326c27d.tar.gz | |
Merge branch '18337-cache-html-in-database' into 'master'
Cache rendered Markdown fields in the database
## What does this MR do?
Introduces cache fields for Markdown-containing fields in the database, and populates them.
## Why was this MR needed?
Rendering Markdown into HTML is performance-intensive. A Redis cache already exists, but this approach is expected to be more performant and reduce unnecessary cache invalidations.
## What are the relevant issue numbers?
Closes #18337
See merge request !6095
Diffstat (limited to 'lib/tasks')
| -rw-r--r-- | lib/tasks/cache.rake | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/lib/tasks/cache.rake b/lib/tasks/cache.rake index 2214f855200..a95a3455a4a 100644 --- a/lib/tasks/cache.rake +++ b/lib/tasks/cache.rake @@ -1,22 +1,33 @@ namespace :cache do - CLEAR_BATCH_SIZE = 1000 # There seems to be no speedup when pushing beyond 1,000 - REDIS_SCAN_START_STOP = '0' # Magic value, see http://redis.io/commands/scan + namespace :clear do + REDIS_CLEAR_BATCH_SIZE = 1000 # There seems to be no speedup when pushing beyond 1,000 + REDIS_SCAN_START_STOP = '0' # Magic value, see http://redis.io/commands/scan - desc "GitLab | Clear redis cache" - task :clear => :environment do - Gitlab::Redis.with do |redis| - cursor = REDIS_SCAN_START_STOP - loop do - cursor, keys = redis.scan( - cursor, - match: "#{Gitlab::Redis::CACHE_NAMESPACE}*", - count: CLEAR_BATCH_SIZE - ) - - redis.del(*keys) if keys.any? - - break if cursor == REDIS_SCAN_START_STOP + desc "GitLab | Clear redis cache" + task redis: :environment do + Gitlab::Redis.with do |redis| + cursor = REDIS_SCAN_START_STOP + loop do + cursor, keys = redis.scan( + cursor, + match: "#{Gitlab::Redis::CACHE_NAMESPACE}*", + count: REDIS_CLEAR_BATCH_SIZE + ) + + redis.del(*keys) if keys.any? + + break if cursor == REDIS_SCAN_START_STOP + end end end + + desc "GitLab | Clear database cache (in the background)" + task db: :environment do + ClearDatabaseCacheWorker.perform_async + end + + task all: [:db, :redis] end + + task clear: 'cache:clear:all' end |
