Refactor: Consolidate caching patterns into shared LocatorCache abstraction#301
Conversation
…ux-global-python Co-authored-by: karthiknadig <3840081+karthiknadig@users.noreply.github.com>
PR Review: Refactor Caching Patterns into Shared LocatorCache Abstractioncc @copilot Overall: Generally good, with a few concerns worth discussing✅ What I Like
|
…st_use] to get_or_insert_with Co-authored-by: karthiknadig <3840081+karthiknadig@users.noreply.github.com>
Addressed in c8f43b0:
Re: other observations:
|
|
Thanks @copilot - the fixes look good!
The explanations for |
LocatorCache<K, V>generic caching abstraction inpet-coreget(),get_or_insert_with(),insert(),contains_key(),clear(),values(),len(),is_empty(), andclone_map()methodsEnvironmentCacheandManagerCachefor common usespet-condato use the new cache abstractionpet-linux-global-pythonto use the new cache abstractioninsert_many()method for atomic batch inserts (addresses lock granularity concern)#[must_use]attribute toget_or_insert_with()pet-linux-global-pythonto useinsert_many()for symlinks + executableSummary
This PR introduces a generic
LocatorCache<K, V>abstraction in thepet-corecrate that consolidates the common caching patterns used across multiple locators. The cache provides:RwLockget_or_insert_with()to prevent redundant computationinsert_many()for better lock efficiencyEnvironmentCache,ManagerCache)Security Summary
No security vulnerabilities were discovered by CodeQL analysis.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.