Throttling Node.js
With our RDF parsing module in place and well tested, let’s turn our attention to getting all those thousands of records into the database.
But one word of caution before we proceed: the code in this section attempts to demonstrate performance-related problems and their solutions. The speed of your hardware and the settings of your operating system may make it easier or harder to see these effects.
Alright—to crawl the cache directory, we’ll use a module called file, which is available through npm.[25] Install and save it as usual, and we’ll begin:
| $ npm install --save file |
The file module has a convenient method called walk() that traverses a directory tree and calls a callback for each file it finds.
Naive File Parsing ...
Get Node.js the Right Way now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.