-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added DscResourceCache #432
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting on changes requested during design review
PR description updated; @SteveL-MSFT please take another look. |
Co-authored-by: Steve Lee <slee@microsoft.com>
Co-authored-by: Steve Lee <slee@microsoft.com>
Co-authored-by: Steve Lee <slee@microsoft.com>
Co-authored-by: Steve Lee <slee@microsoft.com>
if ($PSVersionTable.PSVersion.Major -le 5) { | ||
Join-Path $env:LocalAppData "dsc\WindowsPSAdapterCache.json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this need to be in the if ($IsWindows)
block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows PS does not know "$IsWindows" var; it evaluates to $null there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, forgot about that.
PR Summary
Added caching of
Get-DscResource
results toPSDscAdapter
, reducing execution time for classic PS DSC resources:Before:
After:
Cache location is in user-specific folders:
on Windows -
$env:LocalAppData\dsc\PSAdapterCache.json
for WindowsPS adapter -
$env:LocalAppData\dsc\WindowsPSAdapterCache.json
on Linux/Mac -
$env:HOME/.dsc/PSAdapterCache.json
Checks for stale cache:
a) cache contains every subfolder (+1 level deep to account for new module versions) in
PSModulePath
(i.e. all visible module paths), which is analyzed when cache is accessed.I.e. if
PSModulePath
changes or a module is added/removed from existingPSModulePath
, that is detected, and cache is rebuilt.b) for each resource type cache also contains all
"*.ps1","*.psd1","*psm1","*.mof"
files under$dscResource.ParentPath
and theirLastWrite
timestamps. On accessing the cacheLastWrite
times of live files is compared with those in cache and cache is rebuilt if they are different.