# Swift Package Registry Service

**URL:** <https://forums.swift.org/t/swift-package-registry-service/37219>\
**Category:** Pitches\
**Tags:** packagemanager\
**Created:** [June 4, 2020, 6:20pm UTC](https://forums.swift.org/t/swift-package-registry-service/37219 "2020-06-04T18:20:33Z")\
**Posts on this page:** 1\
**Showing post:** 37

<div class="post-metadata">

**Author:** ![Aciid](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/aciid/32/429_2.png) [@Aciid](https://forums.swift.org/u/Aciid)\
**Post date:** [June 6, 2020, 1:57am UTC](https://forums.swift.org/t/swift-package-registry-service/37219/37 "2020-06-06T01:57:41Z")

</div>

> [@mattt](#):
>
> I think we can take a lot of inspiration from what the [Yarn](https://yarnpkg.com) package manager does with its [offline cache](https://yarnpkg.com/features/offline-cache) and [plug'n'play](https://yarnpkg.com/features/pnp) — especially as we start to consider first-class scripting support for Swift.

Thanks for the links. This made me think what if we actually go ahead and use a per-user cache for holding package sources using [llbuild2](https://forums.swift.org/t/llbuild2/36896)'s new [file-backed CAS implementation](https://github.com/apple/swift-llbuild2/blob/master/Sources/LLBUtil/CAS/FileBackedCASDatabase.swift) (we would also need a small caching layer to look up things in the CAS database but I believe @David_M_Bryson is already working on that). The idea would be that swiftpm will fetch the package sources directly into the CAS and read from it during the dependency resolution. We might end up fetching more versions than actually needed but they will be automatically de-duplicated and shared across all packages on the user's machine. And at the end of the resolution, the checkout too can be done from the CAS so there is no network operation needed there. In the future, we might be able to even skip creating checkouts of the sources as we would be able to directly read them from CAS during the build (provided [llbuild2](https://forums.swift.org/t/llbuild2/36896) + swiftpm-on-llbuild2 experiment works out).

> [@mattt](#):
>
> In fact, that could be a clever solution to the identity problem identified by @rballard and others.

That's an interesting idea but I think there are deeper problems with identity and name clashes that might be worth discussing separately. Some of us (cc @johannesweiss) once discussed introducing a reverse-domain identifier in the package manifest which is used as the identity. And that can also be used by the swift compiler to namespace the modules so you avoid module name clashes (+ you would have some way of disambiguating if needed). However, this is certainly not an easy task and requires a lot of work in the compiler.

> [@mattt](#):
>
> A few questions about implementation:
> 
> - Would the existence of `Package@swift-4.swift` or other tools-versions variants affect behavior in any way? (My guess would be, "No")
> - Any preference in hashing algorithm? (SHA-256?)

I am starting to think that a per-user cache is a better approach and that also simplifies the spec. However, if we do end up using this approach I would expect that the server returns names and hashes of all package manifests present in the package. Using SHA-256 for content hashing makes sense.

---

_[View the full topic](https://forums.swift.org/t/swift-package-registry-service/37219)._
