rattler
rattler copied to clipboard
refactor: put PackageCache into an enum in preparation for a multi-layered package cache
Description
As per https://github.com/conda/rattler/issues/43, we want to implement layered package caches for Rattler. Putting PacakgeCache into an enum allows switching between implementations (SingletonPackageCache and LayeredPackageCache)
I'm considering both traits and enums. Leaning towards enum because:
- My impression is that we don't allow downstream users to add their own PackageCache types, thus a closed set of types (enum) is more suitable.
- Enums are more performant
Stuff to note
- This will be a breaking change
- To let PackageCache be public, I had to make PackageCacheInner public as well (even though
inneris a private struct field), not sure if there's a way not to.
Hey! Thanks for making this PR! Im wondering what your design considerations are. Why have two separate implementations? Isnt a non-layered cache just cache with one layer?
Isnt a non-layered cache just cache with one layer?
Hey @baszalmstra! I was actually referencing this
We could introduce a trait for PackageCache that is implemented for both the current implementation as well as a layered version.
Maybe we can allow users to pick between the singleton and layered implementations, while we polish the latter? Or should we just create a layered implementation and have it be shipped to users (with the default being a cache with one layer)
Maybe we can allow users to pick between the singleton and layered implementations, while we polish the latter? Or should we just create a layered implementation and have it be shipped to users (with the default being a cache with one layer)
Yeah, I think (in hindsight) that makes the most sense.
FYI I'm also about to merge a relatively large refactor of the PackageCache in https://github.com/conda/rattler/pull/837.
Thanks for the heads up on the PR!
Also just to be sure, which idea did you think made the most sense, using the enum or not using it?
Also just to be sure, which idea did you think made the most sense, using the enum or not using it?
I think a single implementation makes more sense. But if you feel uncertain about the implementation using an enum is fine for me as well.
#837 was just merged, you might have a few conflicts.