From fce311377fe1e2f5f65c04cd002566a30ff03130 Mon Sep 17 00:00:00 2001 From: Ajay Date: Fri, 19 Jan 2024 15:16:50 -0500 Subject: [PATCH] Switch to lz4 compression --- package-lock.json | 510 +++++++++++++++++++++++++++-------------- package.json | 2 +- src/utils/redis.ts | 6 +- src/utils/redisKeys.ts | 24 +- 4 files changed, 355 insertions(+), 187 deletions(-) diff --git a/package-lock.json b/package-lock.json index 216c12a..30318be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,6 @@ "version": "0.1.0", "license": "AGPL-3.0-only", "dependencies": { - "@mongodb-js/zstd": "^1.2.0", "axios": "^1.1.3", "better-sqlite3": "^8.0.1", "cron": "^2.1.0", @@ -18,6 +17,7 @@ "express-rate-limit": "^6.7.0", "form-data": "^4.0.0", "lodash": "^4.17.21", + "lz4-napi": "^2.2.0", "pg": "^8.8.0", "rate-limit-redis": "^3.0.1", "redis": "^4.5.0", @@ -63,6 +63,201 @@ "node": ">=6.0.0" } }, + "node_modules/@antoniomuso/lz4-napi-android-arm-eabi": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-android-arm-eabi/-/lz4-napi-android-arm-eabi-2.2.0.tgz", + "integrity": "sha512-9PBt0UhmahcQamcD+eHVB2u38Ae1z7Sqb2zBLExj9DRGT9tRj3RavdgAjRewsShp+k+J2hxfinXp8gLil3rZwg==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@antoniomuso/lz4-napi-android-arm64": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-android-arm64/-/lz4-napi-android-arm64-2.2.0.tgz", + "integrity": "sha512-zW0EPEuSBxjjP9MZUyXmDYAXLpS/TeVEq/la+nJIvM5XtGg1rwvuNdEErO977QI0zRc1jIQBMzE25B/wwP/Bwg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@antoniomuso/lz4-napi-darwin-arm64": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-darwin-arm64/-/lz4-napi-darwin-arm64-2.2.0.tgz", + "integrity": "sha512-KVE5F+fOmVIXADkgSTgA+J3Hv7l2QEaj4iBbLQfuDSZjm5qMDrXUfBJBJv6xKYpu9/ikMZRKvjfU/krhVMqWXw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@antoniomuso/lz4-napi-darwin-x64": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-darwin-x64/-/lz4-napi-darwin-x64-2.2.0.tgz", + "integrity": "sha512-K2jRtXU+9qldL6vK7K4VT3UClZZb87nLqMlwkMVS2eaoofqFdrkSAgJP5oSHN9bkE7u3OCLgOUZfFFSi/UNz7w==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@antoniomuso/lz4-napi-freebsd-x64": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-freebsd-x64/-/lz4-napi-freebsd-x64-2.2.0.tgz", + "integrity": "sha512-KKXiaQ8g0UxwDsfCBH/ARo5FCnoFtoPLDAxz72QLWuuTxfK0epg3ZChb2l1n95bUvSZKRSVQaa7sHJsl+d+ffg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@antoniomuso/lz4-napi-linux-arm-gnueabihf": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-linux-arm-gnueabihf/-/lz4-napi-linux-arm-gnueabihf-2.2.0.tgz", + "integrity": "sha512-p0WkyFmWSaveGPNolSxH23/NksbhORj7D1dxyHdtZKdY1xMUVxQ/aIrD/Vfn35hO01KFI1LVh6nTpybez7Empg==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@antoniomuso/lz4-napi-linux-arm64-gnu": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-linux-arm64-gnu/-/lz4-napi-linux-arm64-gnu-2.2.0.tgz", + "integrity": "sha512-a1C4u+dnS8wP+Lu6fUKGOeVm0tFw8gt0VK+3aCCB9AYu8u2NdfYqqpceu9snNk04Rzp3MNJSryWvHtoVOdUtMQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@antoniomuso/lz4-napi-linux-arm64-musl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-linux-arm64-musl/-/lz4-napi-linux-arm64-musl-2.2.0.tgz", + "integrity": "sha512-+YlKffM2n5/zLJ3JYpzbnwTLj/aiOAM9rEJlDg7LR0YK5o0dbcsCq8fK/fapDkzoLl8BMO6ObJtuZ/6Vi3Targ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@antoniomuso/lz4-napi-linux-x64-gnu": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-linux-x64-gnu/-/lz4-napi-linux-x64-gnu-2.2.0.tgz", + "integrity": "sha512-pPJVppGpV+La0tb34GMTbiUTLsSqIJGzxIdPM2XjJ23u6ytnog2DQiyylMENhY20X7oHG2oQlCW9J+W8sCNh3Q==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@antoniomuso/lz4-napi-linux-x64-musl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-linux-x64-musl/-/lz4-napi-linux-x64-musl-2.2.0.tgz", + "integrity": "sha512-KSWJ5TZVLlOA+hzy7gnYytb7xhD6jeoYqno72Zp/jY1fV5xHk71YJppvzOzVpX4mbRFdu5DMQU8GcvTxsmS2zg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@antoniomuso/lz4-napi-win32-arm64-msvc": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-win32-arm64-msvc/-/lz4-napi-win32-arm64-msvc-2.2.0.tgz", + "integrity": "sha512-bfk4rNPE5Al1aozsRm4oWfMjxS2qDaoYilFzSDWxToFg7DFlAkjBsVLnB9cV+W6oZ/+jowlK8IGFlNhUG+uatw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@antoniomuso/lz4-napi-win32-ia32-msvc": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-win32-ia32-msvc/-/lz4-napi-win32-ia32-msvc-2.2.0.tgz", + "integrity": "sha512-xu7XMe1KyLDP2wzOxTE9eibFGP+Ut1Sl3GbW1zW3wjV4RIXyJqZRvwIOsZ0P0lfXJmykmzN6yIzs1QksOzgMog==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@antoniomuso/lz4-napi-win32-x64-msvc": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-win32-x64-msvc/-/lz4-napi-win32-x64-msvc-2.2.0.tgz", + "integrity": "sha512-sJZjXEIjtK7upjh1oHpDELAH45jL/dNdg/mzYg61ljprtfjsza40h8e/Sq0IQOCmJc6IR746bGcttPM297nhzQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, "node_modules/@babel/code-frame": { "version": "7.22.13", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", @@ -793,126 +988,17 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@mongodb-js/zstd": { + "node_modules/@napi-rs/triples": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/zstd/-/zstd-1.2.0.tgz", - "integrity": "sha512-sKHsJU2MXsp822IFXOHw/4mpFulScNHpZzVy1Zi5k5wBsdiAPx1QramyOXZkpacla+2QPEC/s7TxPlEhG/HuNQ==", - "engines": { - "node": ">= 10" - }, - "optionalDependencies": { - "@mongodb-js/zstd-darwin-arm64": "1.2.0", - "@mongodb-js/zstd-darwin-x64": "1.2.0", - "@mongodb-js/zstd-linux-arm64-gnu": "1.2.0", - "@mongodb-js/zstd-linux-arm64-musl": "1.2.0", - "@mongodb-js/zstd-linux-x64-gnu": "1.2.0", - "@mongodb-js/zstd-linux-x64-musl": "1.2.0", - "@mongodb-js/zstd-win32-x64-msvc": "1.2.0" - } + "resolved": "https://registry.npmjs.org/@napi-rs/triples/-/triples-1.2.0.tgz", + "integrity": "sha512-HAPjR3bnCsdXBsATpDIP5WCrw0JcACwhhrwIAQhiR46n+jm+a2F8kBsfseAuWtSyQ+H3Yebt2k43B5dy+04yMA==" }, - "node_modules/@mongodb-js/zstd-darwin-arm64": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/zstd-darwin-arm64/-/zstd-darwin-arm64-1.2.0.tgz", - "integrity": "sha512-QWgW6IkWp3ErBXOvlOj9lw3lwMfey7eXh/p/Srb/7sEiu1e0yEO+LQ8IctmDWh8bfznKXmwUC0h7LKDbYR30yw==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@mongodb-js/zstd-darwin-x64": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/zstd-darwin-x64/-/zstd-darwin-x64-1.2.0.tgz", - "integrity": "sha512-VnxYO8P2SWubdnydGId5+6veO6Ki6nxCr/pTaDZd8s4Urn6bDdXSX6YsZ0r42dO3Fa0FVYzrlcVAuNB67e2b6w==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@mongodb-js/zstd-linux-arm64-gnu": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/zstd-linux-arm64-gnu/-/zstd-linux-arm64-gnu-1.2.0.tgz", - "integrity": "sha512-TYF0XgNJW6UrvtY2u4Uuo5HiVWNgWNZ/ae2BhVp8hNsDhwFqb/YNoyiZqBei6whUwr8hecMy0UaHAXm3h+O2+Q==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@mongodb-js/zstd-linux-arm64-musl": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/zstd-linux-arm64-musl/-/zstd-linux-arm64-musl-1.2.0.tgz", - "integrity": "sha512-e2ClmJI1BvJq23VSLH14hgjjjcMOad3R/Ap7Q7dTa1uiVSJG4xKd2CmrWQgX1Az4/EfUMWEI7pb4yuanbdd2AQ==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@mongodb-js/zstd-linux-x64-gnu": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/zstd-linux-x64-gnu/-/zstd-linux-x64-gnu-1.2.0.tgz", - "integrity": "sha512-JuoK8lxUlkFPDBfsBUJKnLxpXA5ar+v7G43lIUlBKgjOp5aEWO/qQp5sNgCRnYA7x6PItYqIkEJjsays4N6JOA==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@mongodb-js/zstd-linux-x64-musl": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/zstd-linux-x64-musl/-/zstd-linux-x64-musl-1.2.0.tgz", - "integrity": "sha512-pSb1iUF3Gc/qrJuP/Mi5ry4YFAUdUVFKNRZh1KTDDhSWyRCLd9gKcNdRnXqJjIdeGGEKf4bhtZAbYw4i/g0foA==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@mongodb-js/zstd-win32-x64-msvc": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/zstd-win32-x64-msvc/-/zstd-win32-x64-msvc-1.2.0.tgz", - "integrity": "sha512-iz4Yl+WK3yr/4Yg6F4tKz3X9+yMZDK6pyBMA0CdXydSDZs6o2XQ2I0ZSu3oSk/ACfaZX3SNfRi3XTGgAM1eKZA==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" + "node_modules/@node-rs/helper": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@node-rs/helper/-/helper-1.5.0.tgz", + "integrity": "sha512-4E1laLlg532nkrvUohZzl/wFos3bsHExSDw/guaoLekMcTKtD3ZsH6Vc4/qIRzOzAhQv5LLRnTE+vOeJ6C9Z8w==", + "dependencies": { + "@napi-rs/triples": "^1.2.0" } }, "node_modules/@nodelib/fs.scandir": { @@ -3637,6 +3723,32 @@ "node": "*" } }, + "node_modules/lz4-napi": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/lz4-napi/-/lz4-napi-2.2.0.tgz", + "integrity": "sha512-n2xx3j7rILyd7OXxQoFXmyEpEJywfAXSnK6br2woep7j/7RV86gc7xLTITaM5/KZnQJb5exSvpcz+lTZ8npXgg==", + "dependencies": { + "@node-rs/helper": "^1.3.3" + }, + "engines": { + "node": ">= 10" + }, + "optionalDependencies": { + "@antoniomuso/lz4-napi-android-arm-eabi": "2.2.0", + "@antoniomuso/lz4-napi-android-arm64": "2.2.0", + "@antoniomuso/lz4-napi-darwin-arm64": "2.2.0", + "@antoniomuso/lz4-napi-darwin-x64": "2.2.0", + "@antoniomuso/lz4-napi-freebsd-x64": "2.2.0", + "@antoniomuso/lz4-napi-linux-arm-gnueabihf": "2.2.0", + "@antoniomuso/lz4-napi-linux-arm64-gnu": "2.2.0", + "@antoniomuso/lz4-napi-linux-arm64-musl": "2.2.0", + "@antoniomuso/lz4-napi-linux-x64-gnu": "2.2.0", + "@antoniomuso/lz4-napi-linux-x64-musl": "2.2.0", + "@antoniomuso/lz4-napi-win32-arm64-msvc": "2.2.0", + "@antoniomuso/lz4-napi-win32-ia32-msvc": "2.2.0", + "@antoniomuso/lz4-napi-win32-x64-msvc": "2.2.0" + } + }, "node_modules/make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -5852,6 +5964,84 @@ "@jridgewell/trace-mapping": "^0.3.9" } }, + "@antoniomuso/lz4-napi-android-arm-eabi": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-android-arm-eabi/-/lz4-napi-android-arm-eabi-2.2.0.tgz", + "integrity": "sha512-9PBt0UhmahcQamcD+eHVB2u38Ae1z7Sqb2zBLExj9DRGT9tRj3RavdgAjRewsShp+k+J2hxfinXp8gLil3rZwg==", + "optional": true + }, + "@antoniomuso/lz4-napi-android-arm64": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-android-arm64/-/lz4-napi-android-arm64-2.2.0.tgz", + "integrity": "sha512-zW0EPEuSBxjjP9MZUyXmDYAXLpS/TeVEq/la+nJIvM5XtGg1rwvuNdEErO977QI0zRc1jIQBMzE25B/wwP/Bwg==", + "optional": true + }, + "@antoniomuso/lz4-napi-darwin-arm64": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-darwin-arm64/-/lz4-napi-darwin-arm64-2.2.0.tgz", + "integrity": "sha512-KVE5F+fOmVIXADkgSTgA+J3Hv7l2QEaj4iBbLQfuDSZjm5qMDrXUfBJBJv6xKYpu9/ikMZRKvjfU/krhVMqWXw==", + "optional": true + }, + "@antoniomuso/lz4-napi-darwin-x64": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-darwin-x64/-/lz4-napi-darwin-x64-2.2.0.tgz", + "integrity": "sha512-K2jRtXU+9qldL6vK7K4VT3UClZZb87nLqMlwkMVS2eaoofqFdrkSAgJP5oSHN9bkE7u3OCLgOUZfFFSi/UNz7w==", + "optional": true + }, + "@antoniomuso/lz4-napi-freebsd-x64": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-freebsd-x64/-/lz4-napi-freebsd-x64-2.2.0.tgz", + "integrity": "sha512-KKXiaQ8g0UxwDsfCBH/ARo5FCnoFtoPLDAxz72QLWuuTxfK0epg3ZChb2l1n95bUvSZKRSVQaa7sHJsl+d+ffg==", + "optional": true + }, + "@antoniomuso/lz4-napi-linux-arm-gnueabihf": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-linux-arm-gnueabihf/-/lz4-napi-linux-arm-gnueabihf-2.2.0.tgz", + "integrity": "sha512-p0WkyFmWSaveGPNolSxH23/NksbhORj7D1dxyHdtZKdY1xMUVxQ/aIrD/Vfn35hO01KFI1LVh6nTpybez7Empg==", + "optional": true + }, + "@antoniomuso/lz4-napi-linux-arm64-gnu": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-linux-arm64-gnu/-/lz4-napi-linux-arm64-gnu-2.2.0.tgz", + "integrity": "sha512-a1C4u+dnS8wP+Lu6fUKGOeVm0tFw8gt0VK+3aCCB9AYu8u2NdfYqqpceu9snNk04Rzp3MNJSryWvHtoVOdUtMQ==", + "optional": true + }, + "@antoniomuso/lz4-napi-linux-arm64-musl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-linux-arm64-musl/-/lz4-napi-linux-arm64-musl-2.2.0.tgz", + "integrity": "sha512-+YlKffM2n5/zLJ3JYpzbnwTLj/aiOAM9rEJlDg7LR0YK5o0dbcsCq8fK/fapDkzoLl8BMO6ObJtuZ/6Vi3Targ==", + "optional": true + }, + "@antoniomuso/lz4-napi-linux-x64-gnu": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-linux-x64-gnu/-/lz4-napi-linux-x64-gnu-2.2.0.tgz", + "integrity": "sha512-pPJVppGpV+La0tb34GMTbiUTLsSqIJGzxIdPM2XjJ23u6ytnog2DQiyylMENhY20X7oHG2oQlCW9J+W8sCNh3Q==", + "optional": true + }, + "@antoniomuso/lz4-napi-linux-x64-musl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-linux-x64-musl/-/lz4-napi-linux-x64-musl-2.2.0.tgz", + "integrity": "sha512-KSWJ5TZVLlOA+hzy7gnYytb7xhD6jeoYqno72Zp/jY1fV5xHk71YJppvzOzVpX4mbRFdu5DMQU8GcvTxsmS2zg==", + "optional": true + }, + "@antoniomuso/lz4-napi-win32-arm64-msvc": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-win32-arm64-msvc/-/lz4-napi-win32-arm64-msvc-2.2.0.tgz", + "integrity": "sha512-bfk4rNPE5Al1aozsRm4oWfMjxS2qDaoYilFzSDWxToFg7DFlAkjBsVLnB9cV+W6oZ/+jowlK8IGFlNhUG+uatw==", + "optional": true + }, + "@antoniomuso/lz4-napi-win32-ia32-msvc": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-win32-ia32-msvc/-/lz4-napi-win32-ia32-msvc-2.2.0.tgz", + "integrity": "sha512-xu7XMe1KyLDP2wzOxTE9eibFGP+Ut1Sl3GbW1zW3wjV4RIXyJqZRvwIOsZ0P0lfXJmykmzN6yIzs1QksOzgMog==", + "optional": true + }, + "@antoniomuso/lz4-napi-win32-x64-msvc": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@antoniomuso/lz4-napi-win32-x64-msvc/-/lz4-napi-win32-x64-msvc-2.2.0.tgz", + "integrity": "sha512-sJZjXEIjtK7upjh1oHpDELAH45jL/dNdg/mzYg61ljprtfjsza40h8e/Sq0IQOCmJc6IR746bGcttPM297nhzQ==", + "optional": true + }, "@babel/code-frame": { "version": "7.22.13", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", @@ -6419,62 +6609,19 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "@mongodb-js/zstd": { + "@napi-rs/triples": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/zstd/-/zstd-1.2.0.tgz", - "integrity": "sha512-sKHsJU2MXsp822IFXOHw/4mpFulScNHpZzVy1Zi5k5wBsdiAPx1QramyOXZkpacla+2QPEC/s7TxPlEhG/HuNQ==", + "resolved": "https://registry.npmjs.org/@napi-rs/triples/-/triples-1.2.0.tgz", + "integrity": "sha512-HAPjR3bnCsdXBsATpDIP5WCrw0JcACwhhrwIAQhiR46n+jm+a2F8kBsfseAuWtSyQ+H3Yebt2k43B5dy+04yMA==" + }, + "@node-rs/helper": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@node-rs/helper/-/helper-1.5.0.tgz", + "integrity": "sha512-4E1laLlg532nkrvUohZzl/wFos3bsHExSDw/guaoLekMcTKtD3ZsH6Vc4/qIRzOzAhQv5LLRnTE+vOeJ6C9Z8w==", "requires": { - "@mongodb-js/zstd-darwin-arm64": "1.2.0", - "@mongodb-js/zstd-darwin-x64": "1.2.0", - "@mongodb-js/zstd-linux-arm64-gnu": "1.2.0", - "@mongodb-js/zstd-linux-arm64-musl": "1.2.0", - "@mongodb-js/zstd-linux-x64-gnu": "1.2.0", - "@mongodb-js/zstd-linux-x64-musl": "1.2.0", - "@mongodb-js/zstd-win32-x64-msvc": "1.2.0" + "@napi-rs/triples": "^1.2.0" } }, - "@mongodb-js/zstd-darwin-arm64": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/zstd-darwin-arm64/-/zstd-darwin-arm64-1.2.0.tgz", - "integrity": "sha512-QWgW6IkWp3ErBXOvlOj9lw3lwMfey7eXh/p/Srb/7sEiu1e0yEO+LQ8IctmDWh8bfznKXmwUC0h7LKDbYR30yw==", - "optional": true - }, - "@mongodb-js/zstd-darwin-x64": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/zstd-darwin-x64/-/zstd-darwin-x64-1.2.0.tgz", - "integrity": "sha512-VnxYO8P2SWubdnydGId5+6veO6Ki6nxCr/pTaDZd8s4Urn6bDdXSX6YsZ0r42dO3Fa0FVYzrlcVAuNB67e2b6w==", - "optional": true - }, - "@mongodb-js/zstd-linux-arm64-gnu": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/zstd-linux-arm64-gnu/-/zstd-linux-arm64-gnu-1.2.0.tgz", - "integrity": "sha512-TYF0XgNJW6UrvtY2u4Uuo5HiVWNgWNZ/ae2BhVp8hNsDhwFqb/YNoyiZqBei6whUwr8hecMy0UaHAXm3h+O2+Q==", - "optional": true - }, - "@mongodb-js/zstd-linux-arm64-musl": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/zstd-linux-arm64-musl/-/zstd-linux-arm64-musl-1.2.0.tgz", - "integrity": "sha512-e2ClmJI1BvJq23VSLH14hgjjjcMOad3R/Ap7Q7dTa1uiVSJG4xKd2CmrWQgX1Az4/EfUMWEI7pb4yuanbdd2AQ==", - "optional": true - }, - "@mongodb-js/zstd-linux-x64-gnu": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/zstd-linux-x64-gnu/-/zstd-linux-x64-gnu-1.2.0.tgz", - "integrity": "sha512-JuoK8lxUlkFPDBfsBUJKnLxpXA5ar+v7G43lIUlBKgjOp5aEWO/qQp5sNgCRnYA7x6PItYqIkEJjsays4N6JOA==", - "optional": true - }, - "@mongodb-js/zstd-linux-x64-musl": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/zstd-linux-x64-musl/-/zstd-linux-x64-musl-1.2.0.tgz", - "integrity": "sha512-pSb1iUF3Gc/qrJuP/Mi5ry4YFAUdUVFKNRZh1KTDDhSWyRCLd9gKcNdRnXqJjIdeGGEKf4bhtZAbYw4i/g0foA==", - "optional": true - }, - "@mongodb-js/zstd-win32-x64-msvc": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/zstd-win32-x64-msvc/-/zstd-win32-x64-msvc-1.2.0.tgz", - "integrity": "sha512-iz4Yl+WK3yr/4Yg6F4tKz3X9+yMZDK6pyBMA0CdXydSDZs6o2XQ2I0ZSu3oSk/ACfaZX3SNfRi3XTGgAM1eKZA==", - "optional": true - }, "@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -8466,6 +8613,27 @@ "resolved": "https://registry.npmjs.org/luxon/-/luxon-1.28.1.tgz", "integrity": "sha512-gYHAa180mKrNIUJCbwpmD0aTu9kV0dREDrwNnuyFAsO1Wt0EVYSZelPnJlbj9HplzXX/YWXHFTL45kvZ53M0pw==" }, + "lz4-napi": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/lz4-napi/-/lz4-napi-2.2.0.tgz", + "integrity": "sha512-n2xx3j7rILyd7OXxQoFXmyEpEJywfAXSnK6br2woep7j/7RV86gc7xLTITaM5/KZnQJb5exSvpcz+lTZ8npXgg==", + "requires": { + "@antoniomuso/lz4-napi-android-arm-eabi": "2.2.0", + "@antoniomuso/lz4-napi-android-arm64": "2.2.0", + "@antoniomuso/lz4-napi-darwin-arm64": "2.2.0", + "@antoniomuso/lz4-napi-darwin-x64": "2.2.0", + "@antoniomuso/lz4-napi-freebsd-x64": "2.2.0", + "@antoniomuso/lz4-napi-linux-arm-gnueabihf": "2.2.0", + "@antoniomuso/lz4-napi-linux-arm64-gnu": "2.2.0", + "@antoniomuso/lz4-napi-linux-arm64-musl": "2.2.0", + "@antoniomuso/lz4-napi-linux-x64-gnu": "2.2.0", + "@antoniomuso/lz4-napi-linux-x64-musl": "2.2.0", + "@antoniomuso/lz4-napi-win32-arm64-msvc": "2.2.0", + "@antoniomuso/lz4-napi-win32-ia32-msvc": "2.2.0", + "@antoniomuso/lz4-napi-win32-x64-msvc": "2.2.0", + "@node-rs/helper": "^1.3.3" + } + }, "make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", diff --git a/package.json b/package.json index 3db577d..77ecee7 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "author": "Ajay Ramachandran", "license": "AGPL-3.0-only", "dependencies": { - "@mongodb-js/zstd": "^1.2.0", "axios": "^1.1.3", "better-sqlite3": "^8.0.1", "cron": "^2.1.0", @@ -28,6 +27,7 @@ "express-rate-limit": "^6.7.0", "form-data": "^4.0.0", "lodash": "^4.17.21", + "lz4-napi": "^2.2.0", "pg": "^8.8.0", "rate-limit-redis": "^3.0.1", "redis": "^4.5.0", diff --git a/src/utils/redis.ts b/src/utils/redis.ts index c27d3ce..45e7f57 100644 --- a/src/utils/redis.ts +++ b/src/utils/redis.ts @@ -6,7 +6,7 @@ import { RedisClientOptions } from "@redis/client/dist/lib/client"; import { RedisReply } from "rate-limit-redis"; import { db } from "../databases/databases"; import { Postgres } from "../databases/Postgres"; -import { compress, decompress } from "@mongodb-js/zstd"; +import { compress, uncompress } from "lz4-napi"; export interface RedisStats { activeRequests: number; @@ -68,11 +68,11 @@ if (config.redis?.enabled) { exportClient.getCompressed = (key) => { return exportClient.get(key).then((reply) => { if (reply === null) return null; - return decompress(Buffer.from(reply, "base64")).then((decompressed) => decompressed.toString("utf-8")); + return uncompress(Buffer.from(reply, "base64")).then((decompressed) => decompressed.toString("utf-8")); }); }; exportClient.setCompressed = (key, value, options) => { - return compress(Buffer.from(value as string, "utf-8")).then((compressed) => + return compress(Buffer.from(value as string, "utf-8")).then((compressed) => exportClient.set(key, compressed.toString("base64"), options) ); }; diff --git a/src/utils/redisKeys.ts b/src/utils/redisKeys.ts index 760220d..9d5ca3c 100644 --- a/src/utils/redisKeys.ts +++ b/src/utils/redisKeys.ts @@ -5,43 +5,43 @@ import { Logger } from "./logger"; import { BrandingUUID } from "../types/branding.model"; export const skipSegmentsKey = (videoID: VideoID, service: Service): string => - `segments.v5.${service}.videoID.${videoID}`; + `segments.v6.${service}.videoID.${videoID}`; export const skipSegmentGroupsKey = (videoID: VideoID, service: Service): string => - `segments.groups.v4.${service}.videoID.${videoID}`; + `segments.groups.v5.${service}.videoID.${videoID}`; export function skipSegmentsHashKey(hashedVideoIDPrefix: VideoIDHash, service: Service): string { hashedVideoIDPrefix = hashedVideoIDPrefix.substring(0, 4) as VideoIDHash; if (hashedVideoIDPrefix.length !== 4) Logger.warn(`Redis skip segment hash-prefix key is not length 4! ${hashedVideoIDPrefix}`); - return `segments.v5.${service}.${hashedVideoIDPrefix}`; + return `segments.v6.${service}.${hashedVideoIDPrefix}`; } export const brandingKey = (videoID: VideoID, service: Service): string => - `branding.v3.${service}.videoID.${videoID}`; + `branding.v4.${service}.videoID.${videoID}`; export function brandingHashKey(hashedVideoIDPrefix: VideoIDHash, service: Service): string { hashedVideoIDPrefix = hashedVideoIDPrefix.substring(0, 4) as VideoIDHash; if (hashedVideoIDPrefix.length !== 4) Logger.warn(`Redis skip segment hash-prefix key is not length 4! ${hashedVideoIDPrefix}`); - return `branding.v3.${service}.${hashedVideoIDPrefix}`; + return `branding.v4.${service}.${hashedVideoIDPrefix}`; } export const brandingIPKey = (uuid: BrandingUUID): string => - `branding.v1.shadow.${uuid}`; + `branding.v2.shadow.${uuid}`; export const shadowHiddenIPKey = (videoID: VideoID, timeSubmitted: number, service: Service): string => - `segments.v1.${service}.videoID.${videoID}.shadow.${timeSubmitted}`; + `segments.v2.${service}.videoID.${videoID}.shadow.${timeSubmitted}`; export const reputationKey = (userID: UserID): string => - `reputation.v1.user.${userID}`; + `reputation.v2.user.${userID}`; export function ratingHashKey(hashPrefix: VideoIDHash, service: Service): string { hashPrefix = hashPrefix.substring(0, 4) as VideoIDHash; if (hashPrefix.length !== 4) Logger.warn(`Redis rating hash-prefix key is not length 4! ${hashPrefix}`); - return `rating.v1.${service}.${hashPrefix}`; + return `rating.v2.${service}.${hashPrefix}`; } export function shaHashKey(singleIter: HashedValue): string { @@ -54,15 +54,15 @@ export const tempVIPKey = (userID: HashedUserID): string => `vip.temp.${userID}`; export const videoLabelsKey = (videoID: VideoID, service: Service): string => - `labels.v2.${service}.videoID.${videoID}`; + `labels.v3.${service}.videoID.${videoID}`; export function videoLabelsHashKey(hashedVideoIDPrefix: VideoIDHash, service: Service): string { hashedVideoIDPrefix = hashedVideoIDPrefix.substring(0, 3) as VideoIDHash; if (hashedVideoIDPrefix.length !== 3) Logger.warn(`Redis video labels hash-prefix key is not length 3! ${hashedVideoIDPrefix}`); - return `labels.v2.${service}.${hashedVideoIDPrefix}`; + return `labels.v3.${service}.${hashedVideoIDPrefix}`; } export function userFeatureKey (userID: HashedUserID, feature: Feature): string { - return `user.v1.${userID}.feature.${feature}`; + return `user.v2.${userID}.feature.${feature}`; } \ No newline at end of file