mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-15 10:08:41 -06:00
chore: make redis an enterprise feature (#4314)
This commit is contained in:
committed by
GitHub
parent
91f0d00ba2
commit
762a3ca626
@@ -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);
|
||||
|
||||
@@ -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} */
|
||||
|
||||
Reference in New Issue
Block a user