Skip to content

Replace the imageExistsCache in podman.go with an lru.LRU#11581

Merged
iain-macdonald merged 1 commit intomasterfrom
im/9061d0e4831
Mar 13, 2026
Merged

Replace the imageExistsCache in podman.go with an lru.LRU#11581
iain-macdonald merged 1 commit intomasterfrom
im/9061d0e4831

Conversation

@iain-macdonald
Copy link
Contributor

No description provided.

@iain-macdonald iain-macdonald force-pushed the im/9061d0e4831 branch 2 times, most recently from 17f10e8 to bc7c7fe Compare March 13, 2026 14:33
@iain-macdonald iain-macdonald marked this pull request as ready for review March 13, 2026 14:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR simplifies podman image-existence caching by replacing the custom imageExistsCache wrapper with the shared server/util/lru cache configured with TTL and thread-safety. This keeps the same “cache positive podman image exists results for a short time” behavior while removing bespoke locking/TTL logic.

Changes:

  • Replace *imageExistsCache with lru.LRU[struct{}] in Provider and podmanCommandContainer.
  • Initialize the cache via lru.New using TTL, MaxSize, and ThreadSafe.
  • Update call sites to use Contains and Add(key, value) and remove the custom cache type.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

@vanja-p vanja-p left a comment

Choose a reason for hiding this comment

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

nice

}

imageExistsCache, err := newImageExistsCache()
imageExistsCache, err := lru.New[struct{}](&lru.Config[struct{}]{
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you don't need the type parameter on New, since it infers it from the config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call, done

@iain-macdonald iain-macdonald merged commit 2e17afd into master Mar 13, 2026
12 checks passed
@iain-macdonald iain-macdonald deleted the im/9061d0e4831 branch March 13, 2026 17:33
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.

3 participants