-
Notifications
You must be signed in to change notification settings - Fork 34
Refactor: Consolidate caching patterns across locators into shared abstraction #298
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
Conversation
…r locators to use them Co-authored-by: karthiknadig <3840081+karthiknadig@users.noreply.github.com>
…-poetry caching logic Co-authored-by: karthiknadig <3840081+karthiknadig@users.noreply.github.com>
Review: Request ChangesThanks for working on this refactor! The core abstraction design is solid, but I found a critical bug that needs fixing before this can be merged. ❌ Critical Bug in
|
|
@copilot please resolve conflicts and address comments posted above. |
Co-authored-by: karthiknadig <3840081+karthiknadig@users.noreply.github.com>
Regarding if let Some(exe) = env.executable.clone() {
reported_executables.insert(exe, env.clone());
}This block immediately follows the symlinks loop at lines 121-124. The refactored code correctly calls I've also added two concurrency tests as you suggested ( There are no merge conflicts currently - the working tree is clean. If conflicts appear after main is updated, I'll resolve them. |
LocatorCache<K, V>abstraction inpet-coreLocatorCachewithRwLockfor better read concurrencyCachedValue<V>for simple value caching patternsEnvironmentCache,ManagerCache,EnvironmentListCache)pet-linux-global-pythonto use the new cache abstractionpet-windows-storeto use the new cache abstractionpet-condato use the new cache abstractionpet-poetryto use the new cache abstractionSummary
This PR consolidates duplicate caching patterns across multiple locators into a shared abstraction in
pet-core. The changes include:New Cache Module (
pet-core/src/cache.rs)LocatorCache<K, V>: A generic thread-safe cache usingRwLockfor better read concurrency compared toMutex. Supportsget(),insert(),contains_key(),get_or_insert_with(),clear(),values(), andclone_map()methods.CachedValue<V>: A simpler abstraction for caching single values lazily. Supportsget(),set(),get_or_compute(), andclear()methods.EnvironmentCache,ManagerCache,EnvironmentListCachefor common use cases.Refactored Locators
Arc<Mutex<HashMap<PathBuf, PythonEnvironment>>>withEnvironmentCacheArc<Mutex<Option<Vec<PythonEnvironment>>>>withEnvironmentListCacheArc<Mutex<HashMap<...>>>for both environments and managers withEnvironmentCacheandCondaManagerCacheArc<Mutex<Option<LocatorResult>>>withCachedValue<LocatorResult>Benefits
RwLockinstead ofMutexSecurity Summary
No security vulnerabilities were discovered during the CodeQL analysis.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.