Skip to content

Commit 15ab1bf

Browse files
[D1] Adding wording stating Sessions API is required for RR (#24985)
* Adding wording stating Sessions API is required for RR * Update src/content/docs/d1/best-practices/read-replication.mdx Co-authored-by: Lambros Petrou <[email protected]> --------- Co-authored-by: Lambros Petrou <[email protected]>
1 parent 50c753e commit 15ab1bf

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/content/docs/d1/best-practices/read-replication.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import { GlossaryTooltip, Details, GitHubCode, APIRequest, Tabs, TabItem, TypeSc
1010

1111
D1 read replication can lower latency for read queries and scale read throughput by adding read-only database copies, called read replicas, across regions globally closer to clients.
1212

13-
Your application can use read replicas with D1 [Sessions API](/d1/worker-api/d1-database/#withsession). A session encapsulates all the queries from one logical session for your application. For example, a session may correspond to all queries coming from a particular web browser session. All queries within a session read from a database instance which is as up-to-date as your query needs it to be. Sessions API ensures [sequential consistency](/d1/best-practices/read-replication/#replica-lag-and-consistency-model) for all queries in a session.
13+
To use read replication, you must use the [D1 Sessions API](/d1/worker-api/d1-database/#withsession), otherwise all queries will continue to be executed only by the primary database.
14+
15+
A session encapsulates all the queries from one logical session for your application. For example, a session may correspond to all queries coming from a particular web browser session. All queries within a session read from a database instance which is as up-to-date as your query needs it to be. Sessions API ensures [sequential consistency](/d1/best-practices/read-replication/#replica-lag-and-consistency-model) for all queries in a session.
1416

1517
To checkout D1 read replication, deploy the following Worker code using Sessions API, which will prompt you to create a D1 database and enable read replication on said database.
1618

src/content/docs/d1/worker-api/d1-database.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ const session = env.DB.withSession("<parameter>");
274274

275275
#### Guidance
276276

277-
You can return the last encountered `bookmark` for a given Session using [`session.getBookmark()`](/d1/worker-api/d1-database/#getbookmark).
277+
- To use read replication, you have to use the D1 Sessions API, otherwise all queries will continue to be executed only by the primary database.
278+
- You can return the last encountered `bookmark` for a given Session using [`session.getBookmark()`](/d1/worker-api/d1-database/#getbookmark).
278279

279280
## `D1DatabaseSession` methods
280281

0 commit comments

Comments
 (0)