Skip to content

Commit 6dd958d

Browse files
committed
Fixing / efficient use of tabs.
1 parent 007487b commit 6dd958d

File tree

1 file changed

+27
-44
lines changed

1 file changed

+27
-44
lines changed

src/content/docs/hyperdrive/configuration/query-caching.mdx

Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@ For example, a read query that populates the front page of a news site would be
1919

2020
<Tabs>
2121
<TabItem label="PostgreSQL">
22-
```sql -- Cacheable SELECT * FROM articles WHERE DATE(published_time) =
23-
CURRENT_DATE() ORDER BY published_time DESC LIMIT 50 ```
24-
</TabItem>
25-
<TabItem label="MySQL">
26-
```sql -- Cacheable SELECT * FROM articles WHERE DATE(published_time) =
27-
CURDATE() ORDER BY published_time DESC LIMIT 50 ```
28-
</TabItem>
22+
```sql
23+
-- Cacheable
24+
SELECT * FROM articles WHERE DATE(published_time) =
25+
CURRENT_DATE() ORDER BY published_time DESC LIMIT 50
26+
```
27+
</TabItem>
28+
<TabItem label="MySQL">
29+
```sql
30+
-- Cacheable
31+
SELECT * FROM articles WHERE DATE(published_time) =
32+
CURDATE() ORDER BY published_time DESC LIMIT 50
33+
```
34+
</TabItem>
2935
</Tabs>
3036

3137
Mutating queries (including `INSERT`, `UPSERT`, or `CREATE TABLE`) and queries that use [functions designated as `volatile` by PostgreSQL](https://www.postgresql.org/docs/current/xfunc-volatility.html) are not cached:
@@ -80,38 +86,16 @@ You can also configure multiple Hyperdrive connections from a single application
8086
For example, using database drivers:
8187

8288
<Tabs>
83-
<TabItem label="PostgreSQL">
84-
<Tabs>
85-
<TabItem label="index.ts">
86-
```ts
89+
<TabItem label="PostgreSQL">
90+
```ts title="index.ts"
8791
const client = postgres(env.HYPERDRIVE.connectionString);
8892
// ...
8993
const clientNoCache = postgres(env.HYPERDRIVE_CACHE_DISABLED.connectionString);
90-
```
91-
</TabItem>
92-
<TabItem label="wrangler.jsonc">
93-
```jsonc
94-
{
95-
// Rest of file
96-
"hyperdrive": [
97-
{
98-
"binding": "HYPERDRIVE",
99-
"id": "<YOUR_HYPERDRIVE_CACHE_ENABLED_CONFIGURATION_ID>"
100-
},
101-
{
102-
"binding": "HYPERDRIVE_CACHE_DISABLED",
103-
"id": "<YOUR_HYPERDRIVE_CACHE_DISABLED_CONFIGURATION_ID>"
104-
}
105-
]
106-
}
107-
```
108-
</TabItem>
109-
</Tabs>
110-
</TabItem>
111-
<TabItem label="MySQL">
112-
<Tabs>
113-
<TabItem label="index.ts">
114-
```ts
94+
```
95+
</TabItem>
96+
97+
<TabItem label="MySQL">
98+
```ts title="index.ts"
11599
const connection = createConnection({
116100
host: env.HYPERDRIVE.host,
117101
user: env.HYPERDRIVE.user,
@@ -127,10 +111,13 @@ const connectionNoCache = createConnection({
127111
database: env.HYPERDRIVE_CACHE_DISABLED.database,
128112
port: env.HYPERDRIVE_CACHE_DISABLED.port
129113
});
130-
```
131-
</TabItem>
132-
<TabItem label="wrangler.jsonc">
133-
```jsonc
114+
```
115+
</TabItem>
116+
</Tabs>
117+
118+
The Wrangler configuration remains the same both for PostgreSQL and MySQL.
119+
120+
```jsonc title="wrangler.jsonc"
134121
{
135122
// Rest of file
136123
"hyperdrive": [
@@ -145,10 +132,6 @@ const connectionNoCache = createConnection({
145132
]
146133
}
147134
```
148-
</TabItem>
149-
</Tabs>
150-
</TabItem>
151-
</Tabs>
152135

153136
## Next steps
154137

0 commit comments

Comments
 (0)