Skip to content

Commit 2d08ebe

Browse files
authored
Tidy up the Redis purge script (#18506)
* Improve comment accuracy * Name local constant for the create-client module ref consistently
1 parent b569f84 commit 2d08ebe

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

script/purge-redis-pages.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
// [start-readme]
44
//
5-
// Run this script to manually purge the Redis rendered page cache.
5+
// Run this script to manually "soft purge" the Redis rendered page cache
6+
// by shortening the expiration window of entries.
67
// This will typically only be run by Heroku during the deployment process,
78
// as triggered via our Procfile's "release" phase configuration.
89
//
@@ -11,7 +12,7 @@
1112
require('dotenv').config()
1213

1314
const { promisify } = require('util')
14-
const createClient = require('../lib/redis/create-client')
15+
const createRedisClient = require('../lib/redis/create-client')
1516

1617
const { REDIS_URL, HEROKU_RELEASE_VERSION, HEROKU_PRODUCTION_APP } = process.env
1718
const isHerokuProd = HEROKU_PRODUCTION_APP === 'true'
@@ -45,7 +46,7 @@ console.log({
4546
purgeRenderedPageCache()
4647

4748
function purgeRenderedPageCache () {
48-
const redisClient = createClient({
49+
const redisClient = createRedisClient({
4950
url: REDIS_URL,
5051
db: pageCacheDatabaseNumber
5152
})
@@ -143,7 +144,7 @@ function purgeRenderedPageCache () {
143144
const pexpireAtPipeline = redisClient.batch()
144145

145146
keys.forEach((key, i) => {
146-
// Only operate on -1 result values or those greater than ONE_HOUR_FROM_NOW
147+
// Only operate on -1 values or those later than our desired expiration timestamp
147148
const pttl = pttlResults[i]
148149
// A TTL of -1 means the entry was not configured with any TTL (expiration)
149150
// currently and will remain as a permanent entry unless a TTL is added

0 commit comments

Comments
 (0)