From ac0768dbf33baa268f2afad6615e958432d02286 Mon Sep 17 00:00:00 2001 From: naitik30 Date: Fri, 17 Jan 2025 14:41:02 -0800 Subject: [PATCH 1/2] Update index.js Introduced the `SCAN_CHUNK_SIZE` environment variable to customize the number of keys retrieved per `SCAN` operation, with a default value of 10. Updated the logic in `index.js` to utilize this variable and documented the change in the README. This enhancement allows for greater flexibility and performance tuning based on specific use cases. --- packages/nexrender-database-redis/src/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/nexrender-database-redis/src/index.js b/packages/nexrender-database-redis/src/index.js index b1b0a8e0..25b8b623 100644 --- a/packages/nexrender-database-redis/src/index.js +++ b/packages/nexrender-database-redis/src/index.js @@ -5,6 +5,8 @@ const client = redis.createClient({ url: process.env.REDIS_URL }); +const scanChunkSize = process.env.SCAN_CHUNK_SIZE? process.env.SCAN_CHUNK_SIZE : '10'; + client.getAsync = promisify(client.get).bind(client); client.setAsync = promisify(client.set).bind(client); client.delAsync = promisify(client.del).bind(client); @@ -16,7 +18,7 @@ const scan = async parser => { let results = []; const _scan = async () => { - const [ next, keys ] = await client.scanAsync(cursor, 'MATCH', 'nexjob:*', 'COUNT', '10'); + const [ next, keys ] = await client.scanAsync(cursor, 'MATCH', 'nexjob:*', 'COUNT', scanChunkSize); cursor = next; results = results.concat(keys); From f48d477040e41bef736ec7ca163fbddefc571430 Mon Sep 17 00:00:00 2001 From: naitik30 Date: Fri, 17 Jan 2025 14:41:36 -0800 Subject: [PATCH 2/2] Update readme.md --- packages/nexrender-database-redis/readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/nexrender-database-redis/readme.md b/packages/nexrender-database-redis/readme.md index 822e4199..a0ca1c24 100644 --- a/packages/nexrender-database-redis/readme.md +++ b/packages/nexrender-database-redis/readme.md @@ -11,8 +11,10 @@ npm i @nexrender/database-redis -g ## Configuration In order to use this, `NEXRENDER_DATABASE_PROVIDER` needs to be set to `redis`. +Also you can define the number of keys to retrieve in a single iteration during the `SCAN` operation using `SCAN_CHUNK_SIZE`. Default is `10`. ``` export NEXRENDER_DATABASE_PROVIDER="redis" export REDIS_URL="redis://localhost:6379" +export SCAN_CHUNK_SIZE="100" ```