fix: update online example to support Redis v4+ and remove outdated dependency
This PR updates the Search example to address issues caused by breaking changes in Redis v4+.
The online example was broken due to Redis updates and its reliance on the outdated online package by TJ Holowaychuk, which is no longer maintained and has only 24 weekly downloads.
I considered removing the example or replacing online with another library but opted to add a new file that substitutes the dependency.
Key changes:
- Removed dependency on
onlineby creating a new file,online-tracker.js, which replicates the original functionality. - Switched from callbacks to promises.
- Updated Redis commands and added
try/catchfor error handling. - Refactored Redis initialization into a dedicated function
initializeRedisto make sure that it completes before the server starts.
Note: the original online module was optimized for performance. The substitute file prioritizes simplicity to make it easier to understand, considering it is now part of an example rather than a standalone module.
Tested locally with:
- Redis 7.0.15
- Node.js 22.12.0
- Express 5.0.1
- Debian 12
Let me know if any changes are needed!
Okay, appreciate the inputs. I'll work on that changes and re-request review once it's done.