oclif / core

Node.js Open CLI Framework. Built by Salesforce.

Home Page:https://oclif.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cache findMatches and commandPermutations

AllanOricil opened this issue · comments

What if getCommandPermutations result is cached in a file under ~/.config/<CLI>/permutations so that instead of using CPU we use IO and RAM to load all permutations.
=> When the computed hash of package.json changes, the command permutations cache is invalidated.

The same could be done with findMatches. The cache key is the string used to build the matches array.
=> When the permutations cache is invalidated, findMatches cache should also be invalidated.

Maybe node-persistent-cache can be used to store the cache between command runs in memory and avoid reading files again: https://www.npmjs.com/package/node-persistent-cache

Do you have telemetry data to see the average time, min, max permutations and findMatches takes? If it is a good % of the whole loading time I would try to cache these values.

version 3 caches the permutations in the oclif.manifest.json - provided that the plugin/CLI has flexibleTaxonomy set in the package.json