chore: make redis an enterprise feature (#4314)

This commit is contained in:
Dhruwang Jariwala
2024-11-15 12:40:48 +05:30
committed by GitHub
parent 91f0d00ba2
commit 762a3ca626
2 changed files with 5 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
import { LRUCache } from "lru-cache";
import { REDIS_HTTP_URL } from "@formbricks/lib/constants";
import { ENTERPRISE_LICENSE_KEY, REDIS_HTTP_URL } from "@formbricks/lib/constants";
type Options = {
interval: number;
@@ -41,7 +41,7 @@ const redisRateLimiter = (options: Options) => async (token: string) => {
};
export const rateLimit = (options: Options) => {
if (REDIS_HTTP_URL) {
if (REDIS_HTTP_URL && ENTERPRISE_LICENSE_KEY) {
return redisRateLimiter(options);
} else {
return inMemoryRateLimiter(options);

View File

@@ -11,7 +11,7 @@ const createTimeoutPromise = (ms, rejectReason) => {
CacheHandler.onCreation(async () => {
let client;
if (process.env.REDIS_URL) {
if (process.env.REDIS_URL && process.env.ENTERPRISE_LICENSE_KEY) {
try {
// Create a Redis client.
client = createClient({
@@ -45,6 +45,8 @@ CacheHandler.onCreation(async () => {
});
}
}
} else if (process.env.REDIS_URL) {
console.log("Redis clustering requires an Enterprise License. Falling back to LRU cache.");
}
/** @type {import("@neshca/cache-handler").Handler | null} */