1---
2title: Registry
3description: The registry resolves owner/name to a repository and serves listings. Keep it in a Durable Object or move it to a D1 database.
4---
5
6The examples use `Authentication` from
7[Getting Started](/git/getting-started): the application's request middleware.
8
9The registry is the index. It maps `owner/name` to a repository id,
10enforces that names are unique, and answers listings. Two
11implementations ship, and the rest of the graph cannot tell them
12apart.
13
14## Durable Object
15
16```typescript
17Layer.provide(Git.RegistryDurableObject)
18```
19
20One singleton Durable Object for the whole service. Uniqueness comes
21from its single-threaded transactions, and listings render from
22denormalized columns so listing a thousand repositories touches one
23object rather than a thousand.
24
25The Worker caches resolutions in-isolate for a minute. A stale hit
26fails safe: each repository's Durable Object stores its own
27`owner/name` and rejects a request addressed to a different one.
28
29## D1
30
31```typescript
32const RepoIndex = Cloudflare.D1.Database("RepoIndex");
33
34const GitLive = Git.ApiLive.pipe(
35 Layer.provide(Git.ApiHandlersLive),
36 Layer.provide(Authentication.layer),
37 Layer.provide(Git.ReposDurableObject),
38 Layer.provide(Git.RegistryD1(RepoIndex)),
39 Layer.provide(Git.HasherInline),
40 Layer.provide(Git.BlobStoreR2(GitObjects)),
41);
42```
43
44Same contract, different scaling shape. D1 replicates reads, and
45`owner/name` resolution plus `WHERE owner = ?` listing are what a
46relational store is built for. Writes are rare by comparison: a create,
47a delete, a summary refresh after a push.
48
49Uniqueness moves with it. `PRIMARY KEY (owner, name)` and an insert
50guarded by `WHERE NOT EXISTS` make the create atomic inside SQLite, so
51a losing racer sees `RepoAlreadyExists` exactly as it does on the
52Durable Object. The table is created on first use from the same DDL
53the Durable Object applies.
54
55## Choosing
56
57| | `RegistryDurableObject` | `RegistryD1` |
58| --- | --- | --- |
59| Resolution reads | one object, one region, cached a minute at the Worker | replicated |
60| Listings | denormalized columns in the object | SQL over the table |
61| Creates per second | hundreds | hundreds |
62| Extra resources | none | a D1 database you declare |
63
64Start with the Durable Object. Move to D1 when the registry's single
65region shows up in resolution latency for users far from it, or when
66you want to query the index with SQL from elsewhere.