Merged in fix/batch-size-in-env (pull request #2384)
fix: able to set batch delete size via env * fix: able to set batch delete size via env Approved-by: Linus Flood
This commit is contained in:
@@ -12,7 +12,7 @@ export const env = createEnv({
|
||||
.transform(
|
||||
() =>
|
||||
process.env.BUN_ENV === "production" ||
|
||||
process.env.NODE_ENV === "production"
|
||||
process.env.NODE_ENV === "production",
|
||||
),
|
||||
IS_DEV: z
|
||||
.boolean()
|
||||
@@ -20,7 +20,7 @@ export const env = createEnv({
|
||||
.transform(
|
||||
() =>
|
||||
process.env.BUN_ENV === "development" ||
|
||||
process.env.NODE_ENV === "development"
|
||||
process.env.NODE_ENV === "development",
|
||||
),
|
||||
VERSION: z.string().min(1).default("development"),
|
||||
PORT: z.coerce.number().default(3001),
|
||||
@@ -44,6 +44,7 @@ export const env = createEnv({
|
||||
.refine((s) => s === "true" || s === "false")
|
||||
.transform((s) => s === "true"),
|
||||
SENTRY_TRACE_SAMPLE_RATE: z.coerce.number().default(0.001),
|
||||
DELETE_BATCH_SIZE: z.coerce.number().default(2000),
|
||||
},
|
||||
createFinalSchema: (shape) => {
|
||||
return z.object(shape).transform((env, ctx) => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import { redis } from "@/services/redis";
|
||||
import { loggerModule } from "@/utils/logger";
|
||||
import { timeout } from "@/utils/timeout";
|
||||
import { truncate } from "@/utils/truncate";
|
||||
import { env } from "@/env";
|
||||
|
||||
const MIN_LENGTH = 1;
|
||||
|
||||
@@ -112,7 +113,7 @@ function validateKey(key: string) {
|
||||
|
||||
async function deleteWithPattern(pattern: string) {
|
||||
let cursor = "0";
|
||||
const SCAN_SIZE = 1000;
|
||||
const SCAN_SIZE = env.DELETE_BATCH_SIZE;
|
||||
|
||||
let totalDeleteCount = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user