You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/database/sqlite.mdx
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -310,3 +310,29 @@ export default buildConfig({
310
310
It inherits the options from the SQLite adapter above with the exception of the connection options in favour of the `binding`.
311
311
312
312
You can see our [Cloudflare D1 template](https://github.com/payloadcms/payload/tree/main/templates/with-cloudflare-d1) for a full example of how to set this up.
313
+
314
+
### D1 Read Replicas
315
+
316
+
You can enable read replicas support with the `first-primary` strategy. This is experimental.
317
+
318
+
You must also enable it on your D1 database in the Cloudflare dashboard. Read more about it in the [Cloudflare documentation](https://developers.cloudflare.com/d1/best-practices/read-replication/).
319
+
320
+
<Bannertype="info">
321
+
All write queries are still forwarded to the primary database instance. Read
322
+
replication only improves the response time for read query requests.
// You can also enable read replicas support with the `first-primary` strategy.
333
+
readReplicas: 'first-primary',
334
+
}),
335
+
})
336
+
```
337
+
338
+
You can then verify that they're being used by checking the logs in your Cloudflare dashboard. You should see logs indicating whether a read or write operation was performed, and on which database instance.
Copy file name to clipboardExpand all lines: templates/with-cloudflare-d1/README.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
[](https://deploy.workers.cloudflare.com/?url=https://github.com/payloadcms/payload/tree/main/templates/with-cloudflare-d1)
4
4
5
-
This template comes configured with the bare minimum to get started on anything you need.
5
+
**This can only be deployed on Paid Workers right now due to size limits.**This template comes configured with the bare minimum to get started on anything you need.
6
6
7
7
## Quick start
8
8
@@ -48,6 +48,8 @@ Images will be served from an R2 bucket which you can then further configure to
48
48
49
49
The Worker will have direct access to a D1 SQLite database which Wrangler can connect locally to, just note that you won't have a connection string as you would typically with other providers.
50
50
51
+
You can enable read replicas by adding `readReplicas: 'first-primary'` in the DB adapter and then enabling it on your D1 Cloudflare dashboard. Read more about this feature on [our docs](https://payloadcms.com/docs/database/sqlite#d1-read-replicas).
52
+
51
53
## Working with Cloudflare
52
54
53
55
Firstly, after installing dependencies locally you need to authenticate with Wrangler by running:
0 commit comments