Allow a hash of an project file to be included in the cache key. This is useful for caching project dependencies described in files like package.json for Node, composer.json for PHP etc. The advantage is that it would work efficiently across branches or even projects.
Robin Shen commented 1 year ago
I am afraid this may create too many caches if hash file changed frequently. I am not a node.js developer, but my understanding is that as long as there is a baseline node_moduels cache, running npm install to make it align with current package.json should be very fast.
Robin Shenchanged state to 'Closed'1 year ago
Previous Value
Current Value
Open
Closed
Prabir Shrestha commented 1 year ago
I tried this and it didn’t work as npm install started to fail after few package updates. Seems like it may or may not work. Would be great to have multiple path hash as cache key.
I have of lot of space on my machine so size is not an issue.
Robin Shen commented 1 year ago
How are you specifying the cache key?
Prabir Shrestha commented 1 year ago
I'm using the following: (I have two node_modules folder in the same project)
For each cache key, OneDev creates a separate cache, and then mounts that cache into specified path. It also makes sure that that particular cache is only used by one job run at the same time. However it maybe used by different job runs (or even different jobs if their cache key is the same) at different time. My understanding is that as long as npm install rans as the first command, that cache will be synced with the version specified in package.json even if some package has different versions (due to use in other jobs etc). I did some experiments when implementing the cache, and it seems so. Please correct me if I am wrong on this.
Allow a hash of an project file to be included in the cache key. This is useful for caching project dependencies described in files like package.json for Node, composer.json for PHP etc. The advantage is that it would work efficiently across branches or even projects.