mirror of
https://github.com/tiennm99/github-readme-stats.git
synced 2026-05-28 14:21:36 +00:00
feat: add CACHE_SECONDS environment variable (#2266)
* feat: add CACHE_SECONDS environment variable This commit adds the CACHE_SECONDS environment variable. This variable can be used to circumvent our cache clamping values for self hosted Vercel instances. * refactor: apply formatter
This commit is contained in:
+4
-1
@@ -55,11 +55,14 @@ export default async (req, res) => {
|
||||
parseArray(exclude_repo),
|
||||
);
|
||||
|
||||
const cacheSeconds = clampValue(
|
||||
let cacheSeconds = clampValue(
|
||||
parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10),
|
||||
CONSTANTS.FOUR_HOURS,
|
||||
CONSTANTS.ONE_DAY,
|
||||
);
|
||||
cacheSeconds = process.env.CACHE_SECONDS
|
||||
? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds
|
||||
: cacheSeconds;
|
||||
|
||||
res.setHeader(
|
||||
"Cache-Control",
|
||||
|
||||
@@ -44,6 +44,9 @@ export default async (req, res) => {
|
||||
CONSTANTS.FOUR_HOURS,
|
||||
CONSTANTS.ONE_DAY,
|
||||
);
|
||||
cacheSeconds = process.env.CACHE_SECONDS
|
||||
? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds
|
||||
: cacheSeconds;
|
||||
|
||||
/*
|
||||
if star count & fork count is over 1k then we are kFormating the text
|
||||
|
||||
+4
-1
@@ -62,11 +62,14 @@ export default async (req, res) => {
|
||||
count_weight,
|
||||
);
|
||||
|
||||
const cacheSeconds = clampValue(
|
||||
let cacheSeconds = clampValue(
|
||||
parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10),
|
||||
CONSTANTS.FOUR_HOURS,
|
||||
CONSTANTS.ONE_DAY,
|
||||
);
|
||||
cacheSeconds = process.env.CACHE_SECONDS
|
||||
? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds
|
||||
: cacheSeconds;
|
||||
|
||||
res.setHeader(
|
||||
"Cache-Control",
|
||||
|
||||
@@ -46,6 +46,9 @@ export default async (req, res) => {
|
||||
CONSTANTS.FOUR_HOURS,
|
||||
CONSTANTS.ONE_DAY,
|
||||
);
|
||||
cacheSeconds = process.env.CACHE_SECONDS
|
||||
? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds
|
||||
: cacheSeconds;
|
||||
|
||||
if (!cache_seconds) {
|
||||
cacheSeconds = CONSTANTS.FOUR_HOURS;
|
||||
|
||||
Reference in New Issue
Block a user