mirror of
https://github.com/ahmadk953/tasko.git
synced 2025-01-30 16:43:37 +00:00
Change to ioredis and Update Caching
This commit is contained in:
parent
275e2e4e73
commit
15f879ebb0
5 changed files with 91 additions and 104 deletions
|
@ -1,15 +1,16 @@
|
|||
import { CacheHandler } from '@neshca/cache-handler';
|
||||
import createLruHandler from '@neshca/cache-handler/local-lru';
|
||||
import createRedisHandler from '@neshca/cache-handler/redis-stack';
|
||||
import { createClient } from 'redis';
|
||||
import Redis from 'ioredis';
|
||||
|
||||
CacheHandler.onCreation(async () => {
|
||||
/** @type {import("@neshca/cache-handler").Handler | null} */
|
||||
let handler;
|
||||
|
||||
let client;
|
||||
|
||||
try {
|
||||
client = createClient({
|
||||
url: process.env.REDIS_URL,
|
||||
});
|
||||
client = new Redis(`${process.env.REDIS_URL}`);
|
||||
|
||||
client.on('error', (error) => {
|
||||
if (typeof process.env.NEXT_PRIVATE_DEBUG_CACHE !== 'undefined') {
|
||||
|
@ -26,6 +27,11 @@ CacheHandler.onCreation(async () => {
|
|||
|
||||
await client.connect();
|
||||
console.info('Redis client connected.');
|
||||
|
||||
handler = createRedisHandler({
|
||||
client,
|
||||
timeoutMs: 1000,
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Failed to connect Redis client:', error);
|
||||
|
||||
|
@ -40,25 +46,14 @@ CacheHandler.onCreation(async () => {
|
|||
'Failed to quit the Redis client after failing to connect.'
|
||||
);
|
||||
});
|
||||
|
||||
handler = createLruHandler();
|
||||
console.warn(
|
||||
'Falling back to LRU handler because Redis client is not available.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {import("@neshca/cache-handler").Handler | null} */
|
||||
let handler;
|
||||
|
||||
if (client?.isReady) {
|
||||
handler = await createRedisHandler({
|
||||
client,
|
||||
keyPrefix: 'tasko:',
|
||||
timeoutMs: 1000,
|
||||
});
|
||||
} else {
|
||||
handler = createLruHandler();
|
||||
console.warn(
|
||||
'Falling back to LRU handler because Redis client is not available.'
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
handlers: [handler],
|
||||
};
|
||||
|
|
|
@ -55,6 +55,7 @@ const nextConfig: NextConfig = {
|
|||
process.env.NODE_ENV === 'production'
|
||||
? require.resolve('./cache-handler.mjs')
|
||||
: undefined,
|
||||
cacheMaxMemorySize: process.env.NODE_ENV === 'production' ? 0 : undefined,
|
||||
};
|
||||
|
||||
const withMDX = createMDX({});
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
"clsx": "^2.1.1",
|
||||
"date-fns": "^4.1.0",
|
||||
"dompurify": "^3.2.3",
|
||||
"ioredis": "^5.4.2",
|
||||
"lodash": "^4.17.21",
|
||||
"lucide-react": "^0.473.0",
|
||||
"next": "^15.1.6",
|
||||
|
@ -55,7 +56,6 @@
|
|||
"react": "^19.0.0",
|
||||
"react-day-picker": "^9.5.0",
|
||||
"react-dom": "^19.0.0",
|
||||
"redis": "^4.7.0",
|
||||
"sharp": "^0.33.5",
|
||||
"sonner": "^1.7.2",
|
||||
"stripe": "^17.4.0",
|
||||
|
|
|
@ -9,7 +9,7 @@ Sentry.init({
|
|||
|
||||
integrations: [
|
||||
Sentry.redisIntegration({
|
||||
cachePrefixes: ['tasko:'],
|
||||
cachePrefixes: [''],
|
||||
}),
|
||||
],
|
||||
|
||||
|
|
155
yarn.lock
155
yarn.lock
|
@ -1554,6 +1554,13 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@ioredis/commands@npm:^1.1.1":
|
||||
version: 1.2.0
|
||||
resolution: "@ioredis/commands@npm:1.2.0"
|
||||
checksum: 10c0/a5d3c29dd84d8a28b7c67a441ac1715cbd7337a7b88649c0f17c345d89aa218578d2b360760017c48149ef8a70f44b051af9ac0921a0622c2b479614c4f65b36
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@isaacs/cliui@npm:^8.0.2":
|
||||
version: 8.0.2
|
||||
resolution: "@isaacs/cliui@npm:8.0.2"
|
||||
|
@ -3653,62 +3660,6 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@redis/bloom@npm:1.2.0":
|
||||
version: 1.2.0
|
||||
resolution: "@redis/bloom@npm:1.2.0"
|
||||
peerDependencies:
|
||||
"@redis/client": ^1.0.0
|
||||
checksum: 10c0/7dde8e67188164e96226c8a5c78ebd2801f1662947371e78fb95fb180c1e9ddff8d237012eb5e9182775be61cb546f67f759927cdaee0d178d863ee290e1fb27
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@redis/client@npm:1.6.0":
|
||||
version: 1.6.0
|
||||
resolution: "@redis/client@npm:1.6.0"
|
||||
dependencies:
|
||||
cluster-key-slot: "npm:1.1.2"
|
||||
generic-pool: "npm:3.9.0"
|
||||
yallist: "npm:4.0.0"
|
||||
checksum: 10c0/c80a01b4f72d32284515dac6d1aefe0e9c881d08b8db33281f87b51650c1c116b18074a29ca81599d15dccb37b29eef9b26a75a5755150ae27d163e680c34bf6
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@redis/graph@npm:1.1.1":
|
||||
version: 1.1.1
|
||||
resolution: "@redis/graph@npm:1.1.1"
|
||||
peerDependencies:
|
||||
"@redis/client": ^1.0.0
|
||||
checksum: 10c0/64199db2cb3669c4911af8aba3b7116c4c2c1df37ca74b2a65555e62c863935a0cea74bc41bd92acf2e551074eb2a30c75f54a9f439b40e0f9bb67fc5fb66614
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@redis/json@npm:1.0.7":
|
||||
version: 1.0.7
|
||||
resolution: "@redis/json@npm:1.0.7"
|
||||
peerDependencies:
|
||||
"@redis/client": ^1.0.0
|
||||
checksum: 10c0/cef473711d66f7568a16edbd728acca7d237cfeaa15e0326b5b628dfab4afc0c76c7354e7f8efad6ecc64a1cb774e4aa060ee46497b633e18ba0a2f0aace1cc4
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@redis/search@npm:1.2.0":
|
||||
version: 1.2.0
|
||||
resolution: "@redis/search@npm:1.2.0"
|
||||
peerDependencies:
|
||||
"@redis/client": ^1.0.0
|
||||
checksum: 10c0/01d57ac10d2c5698e04e4a2f945440db3087e8834643ca950c099879dbcd77526604ca6f5c2ee883dfd4b337b0a24cb7d81ac56845aa83f89a4f161362a08dc6
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@redis/time-series@npm:1.1.0":
|
||||
version: 1.1.0
|
||||
resolution: "@redis/time-series@npm:1.1.0"
|
||||
peerDependencies:
|
||||
"@redis/client": ^1.0.0
|
||||
checksum: 10c0/503d0d5cbc9113d26666bb7b4dea57619badbcdfeee0369abf647250f26c5482ed5827c83f88f9f0cf22e021e3e7cb562459669d733fac05652972e208d6ba0f
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@rollup/plugin-commonjs@npm:28.0.1":
|
||||
version: 28.0.1
|
||||
resolution: "@rollup/plugin-commonjs@npm:28.0.1"
|
||||
|
@ -5771,7 +5722,7 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"cluster-key-slot@npm:1.1.2":
|
||||
"cluster-key-slot@npm:1.1.2, cluster-key-slot@npm:^1.1.0":
|
||||
version: 1.1.2
|
||||
resolution: "cluster-key-slot@npm:1.1.2"
|
||||
checksum: 10c0/d7d39ca28a8786e9e801eeb8c770e3c3236a566625d7299a47bb71113fb2298ce1039596acb82590e598c52dbc9b1f088c8f587803e697cb58e1867a95ff94d3
|
||||
|
@ -6154,6 +6105,13 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"denque@npm:^2.1.0":
|
||||
version: 2.1.0
|
||||
resolution: "denque@npm:2.1.0"
|
||||
checksum: 10c0/f9ef81aa0af9c6c614a727cb3bd13c5d7db2af1abf9e6352045b86e85873e629690f6222f4edd49d10e4ccf8f078bbeec0794fafaf61b659c0589d0c511ec363
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"deprecation@npm:^2.0.0":
|
||||
version: 2.3.1
|
||||
resolution: "deprecation@npm:2.3.1"
|
||||
|
@ -7526,13 +7484,6 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"generic-pool@npm:3.9.0":
|
||||
version: 3.9.0
|
||||
resolution: "generic-pool@npm:3.9.0"
|
||||
checksum: 10c0/6b314d0d71170d5cbaf7162c423f53f8d6556b2135626a65bcdc03c089840b0a2f59eeb2d907939b8200e945eaf71ceb6630426f22d2128a1d242aec4b232aa7
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"gensync@npm:^1.0.0-beta.2":
|
||||
version: 1.0.0-beta.2
|
||||
resolution: "gensync@npm:1.0.0-beta.2"
|
||||
|
@ -8057,6 +8008,23 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"ioredis@npm:^5.4.2":
|
||||
version: 5.4.2
|
||||
resolution: "ioredis@npm:5.4.2"
|
||||
dependencies:
|
||||
"@ioredis/commands": "npm:^1.1.1"
|
||||
cluster-key-slot: "npm:^1.1.0"
|
||||
debug: "npm:^4.3.4"
|
||||
denque: "npm:^2.1.0"
|
||||
lodash.defaults: "npm:^4.2.0"
|
||||
lodash.isarguments: "npm:^3.1.0"
|
||||
redis-errors: "npm:^1.2.0"
|
||||
redis-parser: "npm:^3.0.0"
|
||||
standard-as-callback: "npm:^2.1.0"
|
||||
checksum: 10c0/e59d2cceb43ed74b487d7b50fa91b93246e734e5d4835c7e62f64e44da072f12ab43b044248012e6f8b76c61a7c091a2388caad50e8ad69a8ce5515a730b23b8
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"ip-address@npm:^9.0.5":
|
||||
version: 9.0.5
|
||||
resolution: "ip-address@npm:9.0.5"
|
||||
|
@ -9281,6 +9249,20 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"lodash.defaults@npm:^4.2.0":
|
||||
version: 4.2.0
|
||||
resolution: "lodash.defaults@npm:4.2.0"
|
||||
checksum: 10c0/d5b77aeb702caa69b17be1358faece33a84497bcca814897383c58b28a2f8dfc381b1d9edbec239f8b425126a3bbe4916223da2a576bb0411c2cefd67df80707
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"lodash.isarguments@npm:^3.1.0":
|
||||
version: 3.1.0
|
||||
resolution: "lodash.isarguments@npm:3.1.0"
|
||||
checksum: 10c0/5e8f95ba10975900a3920fb039a3f89a5a79359a1b5565e4e5b4310ed6ebe64011e31d402e34f577eca983a1fc01ff86c926e3cbe602e1ddfc858fdd353e62d8
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"lodash.isplainobject@npm:^4.0.6":
|
||||
version: 4.0.6
|
||||
resolution: "lodash.isplainobject@npm:4.0.6"
|
||||
|
@ -11425,17 +11407,19 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"redis@npm:^4.7.0":
|
||||
version: 4.7.0
|
||||
resolution: "redis@npm:4.7.0"
|
||||
"redis-errors@npm:^1.0.0, redis-errors@npm:^1.2.0":
|
||||
version: 1.2.0
|
||||
resolution: "redis-errors@npm:1.2.0"
|
||||
checksum: 10c0/5b316736e9f532d91a35bff631335137a4f974927bb2fb42bf8c2f18879173a211787db8ac4c3fde8f75ed6233eb0888e55d52510b5620e30d69d7d719c8b8a7
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"redis-parser@npm:^3.0.0":
|
||||
version: 3.0.0
|
||||
resolution: "redis-parser@npm:3.0.0"
|
||||
dependencies:
|
||||
"@redis/bloom": "npm:1.2.0"
|
||||
"@redis/client": "npm:1.6.0"
|
||||
"@redis/graph": "npm:1.1.1"
|
||||
"@redis/json": "npm:1.0.7"
|
||||
"@redis/search": "npm:1.2.0"
|
||||
"@redis/time-series": "npm:1.1.0"
|
||||
checksum: 10c0/a05632a58adbcaa4566238073cd6d00ed008522d2ef015a31aaef200c184a4eff4fa007c514eda91dda1e1205350b5901d0c7b58824dbfa593feb81a0087bf4d
|
||||
redis-errors: "npm:^1.0.0"
|
||||
checksum: 10c0/ee16ac4c7b2a60b1f42a2cdaee22b005bd4453eb2d0588b8a4939718997ae269da717434da5d570fe0b05030466eeb3f902a58cf2e8e1ca058bf6c9c596f632f
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
@ -12221,6 +12205,13 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"standard-as-callback@npm:^2.1.0":
|
||||
version: 2.1.0
|
||||
resolution: "standard-as-callback@npm:2.1.0"
|
||||
checksum: 10c0/012677236e3d3fdc5689d29e64ea8a599331c4babe86956bf92fc5e127d53f85411c5536ee0079c52c43beb0026b5ce7aa1d834dd35dd026e82a15d1bcaead1f
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"std-env@npm:^3.7.0":
|
||||
version: 3.8.0
|
||||
resolution: "std-env@npm:3.8.0"
|
||||
|
@ -12662,6 +12653,7 @@ __metadata:
|
|||
eslint-config-prettier: "npm:^10.0.1"
|
||||
eslint-plugin-react-compiler: "npm:^19.0.0-beta-55955c9-20241229"
|
||||
fluid-tailwind: "npm:^1.0.4"
|
||||
ioredis: "npm:^5.4.2"
|
||||
jest: "npm:^29.7.0"
|
||||
jest-environment-jsdom: "npm:^29.7.0"
|
||||
jest-junit: "npm:^16.0.0"
|
||||
|
@ -12676,7 +12668,6 @@ __metadata:
|
|||
react: "npm:^19.0.0"
|
||||
react-day-picker: "npm:^9.5.0"
|
||||
react-dom: "npm:^19.0.0"
|
||||
redis: "npm:^4.7.0"
|
||||
sharp: "npm:^0.33.5"
|
||||
sonner: "npm:^1.7.2"
|
||||
stripe: "npm:^17.4.0"
|
||||
|
@ -13630,13 +13621,6 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"yallist@npm:4.0.0, yallist@npm:^4.0.0":
|
||||
version: 4.0.0
|
||||
resolution: "yallist@npm:4.0.0"
|
||||
checksum: 10c0/2286b5e8dbfe22204ab66e2ef5cc9bbb1e55dfc873bbe0d568aa943eb255d131890dfd5bf243637273d31119b870f49c18fcde2c6ffbb7a7a092b870dc90625a
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"yallist@npm:^3.0.2":
|
||||
version: 3.1.1
|
||||
resolution: "yallist@npm:3.1.1"
|
||||
|
@ -13644,6 +13628,13 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"yallist@npm:^4.0.0":
|
||||
version: 4.0.0
|
||||
resolution: "yallist@npm:4.0.0"
|
||||
checksum: 10c0/2286b5e8dbfe22204ab66e2ef5cc9bbb1e55dfc873bbe0d568aa943eb255d131890dfd5bf243637273d31119b870f49c18fcde2c6ffbb7a7a092b870dc90625a
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"yallist@npm:^5.0.0":
|
||||
version: 5.0.0
|
||||
resolution: "yallist@npm:5.0.0"
|
||||
|
|
Loading…
Reference in a new issue