Skip to content

Conversation

@cobya
Copy link
Contributor

@cobya cobya commented Mar 23, 2022

Updates the caching mechanism in IPyPiClient from using a ConcurrentDictionary to a Microsoft.Extensions.Caching.Memory MemoryCache which allows setting a maximum number of cache entries and a cache entry expiration time. By limiting the number of entries the memory usage will be lowered and because of expiration time if the tool has not finished by the time the cache is no longer being used memory will be freed before exiting the program.

For users that need additional configuration (potentially due to memory constraints), allow them to set a maximum number of cache entries using the PyPiMaxCacheEntries environment variable.

This resolves the issue #35

@cobya cobya requested a review from a team as a code owner March 23, 2022 23:38
@cobya cobya requested a review from RushabhBhansali March 23, 2022 23:38
@github-actions
Copy link

👋 Hi! It looks like you modified some files in the Detectors folder.
You may need to bump the detector versions if any of the following scenarios apply:

  • The detector detects more or fewer components than before
  • The detector generates different parent/child graph relationships than before
  • The detector generates different devDependencies values than before

If none of the above scenarios apply, feel free to ignore this comment 🙂

Comment on lines +42 to +43
private const long CACHEINTERVALSECONDS = 60;
private const long DEFAULTCACHEENTRIES = 128;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were this just an estimate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they are currently an estimate, but introduced a new telemetry class to track cache usage statistics so we can adjust in the future.

JamieMagee added a commit that referenced this pull request Mar 24, 2022
JamieMagee added a commit that referenced this pull request Mar 24, 2022
@JamieMagee
Copy link
Member

JamieMagee commented Mar 24, 2022

@cobya Sorry! I accidentally had the wrong issue number in my PR.

@JamieMagee JamieMagee reopened this Mar 24, 2022
@cobya cobya merged commit ee44b89 into main Mar 24, 2022
@cobya cobya deleted the cobya/PyPyCache branch March 24, 2022 22:35
@cobya cobya linked an issue Mar 28, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IPyPiClient response caching strategy should be improved

3 participants