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: src/content/docs/durable-objects/api/storage-api.mdx
+18-2Lines changed: 18 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -191,7 +191,21 @@ The `put()` method returns a `Promise`, but most applications can discard this p
191
191
192
192
*`txn`
193
193
194
-
* Provides access to the `put()`, `get()`, `delete()` and `list()` methods documented above to run in the current transaction context. In order to get transactional behavior within a transaction closure, you must call the methods on the `txn` Object instead of on the top-level `state.storage` Object.<br/><br/>Also supports a `rollback()` function that ensures any changes made during the transaction will be rolled back rather than committed. After `rollback()` is called, any subsequent operations on the `txn` Object will fail with an exception. `rollback()` takes no parameters and returns nothing to the caller.
194
+
* Provides access to the `put()`, `get()`, `delete()` and `list()` methods documented above to run in the current transaction context. In order to get transactional behavior within a transaction closure, you must call the methods on the `txn` Object instead of on the top-level `ctx.storage` Object.<br/><br/>Also supports a `rollback()` function that ensures any changes made during the transaction will be rolled back rather than committed. After `rollback()` is called, any subsequent operations on the `txn` Object will fail with an exception. `rollback()` takes no parameters and returns nothing to the caller.
195
+
196
+
* When using [the SQLite-backed storage engine](/durable-objects/best-practices/access-durable-objects-storage/#sqlite-storage-backend), the `txn` object is obsolete. Any storage operations performed directly on the `ctx.storage` object, including SQL queries using [`ctx.storage.sql.exec()`](#sqlexec), will be considered part of the transaction.
197
+
198
+
### transactionSync
199
+
200
+
*`transactionSync(callback)`: <Typetext='any' />
201
+
202
+
* Only available when using [the SQLite-backed storage engine](/durable-objects/best-practices/access-durable-objects-storage/#sqlite-storage-backend).
203
+
204
+
* Invokes `callback()` wrapped in a transaction, and returns its result.
205
+
206
+
* If `callback()` throws an exception, the transaction will be rolled back.
207
+
208
+
* The callback must complete synchronously, that is, it should not be declared `async` nor otherwise return a Promise. Only synchronous storage operations can be part of the transaction. This is intended for use with SQL queries using [`ctx.storage.sql.exec()`](#sqlexec), which complete sychronously.
195
209
196
210
### sync
197
211
@@ -233,7 +247,7 @@ The `put()` method returns a `Promise`, but most applications can discard this p
233
247
234
248
:::note[SQLite in Durable Objects Beta]
235
249
236
-
SQL API methods accessed with `ctx.storage.sql` are only allowed on [Durable Object classes with SQLite storage backend](/durable-objects/reference/durable-objects-migrations/#enable-sqlite-storage-backend-on-create-durable-object-class-migration) and will return an error if called on Durable Object classes with a key-value storage backend.
250
+
SQL API methods accessed with `ctx.storage.sql` are only allowed on [Durable Object classes with SQLite storage backend](/durable-objects/reference/durable-objects-migrations/#enable-sqlite-storage-backend-on-new-durable-object-class-migration) and will return an error if called on Durable Object classes with a key-value storage backend.
237
251
238
252
:::
239
253
@@ -282,6 +296,8 @@ A cursor (`SqlStorageCursor`) to iterate over query row results as objects. `Sql
282
296
*`rowsWritten`: <Typetext='number' />
283
297
* The number of rows written so far as part of this SQL `query`. This may increase as you iterate the cursor. The final value is used for [SQL billing](/durable-objects/platform/pricing/#sqlite-storage-backend).
284
298
299
+
Note that `sql.exec()` cannot execute transaction-related statements like `BEGIN TRANSACTION` or `SAVEPOINT`. Instead, use the [`ctx.storage.transaction()`](#transaction) or [`ctx.storage.transactionSync()`](#transactionsync) APIs to start a transaction, and then execute SQL queries in your callback.
Copy file name to clipboardExpand all lines: src/content/docs/reference-architecture/by-solution.mdx
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,18 +43,27 @@ Architecture documentation related to using Cloudflare for Zero Trust, SSE and S
43
43
-[Securing data at rest](/reference-architecture/diagrams/security/securing-data-at-rest/)
44
44
-[Securing data in transit](/reference-architecture/diagrams/security/securing-data-in-transit/)
45
45
-[Securing data in use](/reference-architecture/diagrams/security/securing-data-in-use/)
46
+
-[Extend ZTNA with external authorization and serverless computing](/reference-architecture/diagrams/sase/augment-access-with-serverless/)
46
47
47
48
#### Design guides
48
49
49
50
-[Building zero trust architecture into your startup](/reference-architecture/design-guides/zero-trust-for-startups/)
50
51
-[Network-focused migration from VPN concentrators to Zero Trust Network Access](/reference-architecture/design-guides/network-vpn-migration/)
52
+
-[Using a zero trust framework to secure SaaS applications](/reference-architecture/design-guides/zero-trust-for-saas/)
51
53
52
54
#### Implementation guides
53
55
54
56
-[Secure your Internet traffic and SaaS apps](/learning-paths/secure-internet-traffic/)
55
57
-[Replace your VPN](/learning-paths/replace-vpn/)
56
58
-[Deploy Zero Trust Web Access](/learning-paths/zero-trust-web-access/)
57
59
60
+
### Networking
61
+
62
+
#### Reference architecture diagrams
63
+
64
+
-[Protect public networks with Cloudflare](/reference-architecture/diagrams/network/protect-public-networks-with-cloudflare/)
65
+
-[Bring your own IP space to Cloudflare](/reference-architecture/diagrams/network/bring-your-own-ip-space-to-cloudflare/)
66
+
58
67
### Application Performance
59
68
60
69
Content related to DNS, caching, load balancing and other Cloudflare services designed to improve application reliability and performance.
@@ -68,6 +77,11 @@ Content related to DNS, caching, load balancing and other Cloudflare services de
68
77
69
78
Content related to protecting your applications from threats such as DDoS attack, SQL injection, exploiting application vulnerabilities, scraping API data and more.
-[Ingesting BigQuery Data into Workers AI](/reference-architecture/diagrams/ai/bigquery-workers-ai/)
103
+
104
+
##### Serverless
105
+
86
106
-[Optimizing Image Delivery with Cloudflare Image Resizing and R2](/reference-architecture/diagrams/content-delivery/optimizing-image-delivery-with-cloudflare-image-resizing-and-r2/)
87
107
-[A/B-testing using Workers](/reference-architecture/diagrams/serverless/a-b-testing-using-workers/)
- When making changes to your Durable Object classes, you must perform a migration. Refer to [Durable Object migrations](/durable-objects/reference/durable-objects-migrations/).
- Enables Workers Trace Events Logpush for a Worker. Any scripts with this property will automatically get picked up by the Workers Logpush job configured for your account. Defaults to `false`.
168
+
- Enables Workers Trace Events Logpush for a Worker. Any scripts with this property will automatically get picked up by the Workers Logpush job configured for your account. Defaults to `false`. Refer to [Workers Logpush](/workers/observability/logs/logpush/).
- Configures automatic observability settings for telemetry data emitted from your Worker. Refer to [Observability](#observability).
173
177
@@ -322,6 +326,26 @@ Example:
322
326
crons = ["* * * * *"]
323
327
```
324
328
329
+
## Observability
330
+
331
+
The [Observability](/workers/observability/logs/workers-logs) setting allows you to automatically ingest, store, filter, and analyze logging data emitted from Cloudflare Workers directly from your Cloudflare Worker's dashboard.
- A number between 0 and 1, where 0 indicates zero out of one hundred requests are logged, and 1 indicates every request is logged. If `head_sampling_rate` is unspecified, it is configured to a default value of 1 (100%). Read more about [head-based sampling](/workers/observability/logs/workers-logs/#head-based-sampling).
339
+
340
+
Example:
341
+
342
+
```toml title="wrangler.toml"
343
+
[observability]
344
+
enabled = true
345
+
head_sampling_rate = 0.1# 10% of requests are logged
346
+
```
347
+
348
+
325
349
## Custom builds
326
350
327
351
You can configure a custom build step that will be run before your Worker is deployed. Refer to [Custom builds](/workers/wrangler/custom-builds/).
@@ -510,7 +534,7 @@ When making changes to your Durable Object classes, you must perform a migration
510
534
511
535
- The new Durable Objects being defined.
512
536
513
-
-`renamed_classes` <Typetext="from: string, to: string}[]" /> <MetaInfotext="optional" />
537
+
-`renamed_classes` <Typetext="{from: string, to: string}[]" /> <MetaInfotext="optional" />
514
538
515
539
- The Durable Objects being renamed.
516
540
@@ -629,28 +653,6 @@ binding = "<BINDING_NAME2>"
629
653
id = "<NAMESPACE_ID2>"
630
654
```
631
655
632
-
### Observability
633
-
634
-
The [Observability](/workers/observability/logs/workers-logs) setting allows you to automatically ingest, store, filter, and analyze logging data emitted from Cloudflare Workers directly from your Cloudflare Worker's dashboard.
635
-
636
-
-`enabled` boolean required
637
-
638
-
- When set to `true` on a Worker, logs for the Worker are persisted. Defaults to `true` for all new Workers.
639
-
640
-
-`head_sampling_rate` number optional
641
-
- A number between 0 and 1, where 0 indicates zero out of one hundred requests are logged, and 1 indicates every request is logged. If `head_sampling_rate` is unspecified, it is configured to a default value of 1 (100%). Read more about [head-based sampling](/workers/observability/logs/workers-logs/#head-based-sampling).
642
-
643
-
Example:
644
-
645
-
```toml title="wrangler.toml"
646
-
[observability]
647
-
enabled = true
648
-
649
-
[observability]
650
-
enabled = true
651
-
head_sampling_rate = 0.1# 10% of requests are logged
652
-
```
653
-
654
656
### Queues
655
657
656
658
[Queues](/queues/) is Cloudflare's global message queueing service, providing [guaranteed delivery](/queues/reference/delivery-guarantees/) and [message batching](/queues/configuration/batching-retries/). To interact with a queue with Workers, you need a producer Worker to send messages to the queue and a consumer Worker to pull batches of messages out of the Queue. A single Worker can produce to and consume from multiple Queues.
Copy file name to clipboardExpand all lines: src/content/partials/workers/storage_api_pricing.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ You can introspect rows read and rows written using `cursor.rowsRead` and `curso
42
42
43
43
:::
44
44
45
-
For [Durable Objects classes with SQLite storage backend](/durable-objects/reference/durable-objects-migrations/#enable-sqlite-storage-backend-on-create-durable-object-class-migration) via `ctx.storage.sql` the following pricing is used instead:
45
+
For [Durable Objects classes with SQLite storage backend](/durable-objects/reference/durable-objects-migrations/#enable-sqlite-storage-backend-on-new-durable-object-class-migration) via `ctx.storage.sql` the following pricing is used instead:
0 commit comments