Skip to content

Commit 2735451

Browse files
committed
add code to changelogs
1 parent 9d23c24 commit 2735451

File tree

2 files changed

+55
-7
lines changed

2 files changed

+55
-7
lines changed

src/content/changelog/durable-objects/2025-04-07-durable-objects-free-tier.mdx

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,46 @@ description: Durable Objects now available on Workers Free plan.
44
products:
55
- durable-objects
66
- workers
7-
date: 2025-04-07T13:00:00Z
7+
date: 2025-04-07T06:00:00Z
88
---
99

10-
Durable Objects can now be used with zero commitment on the [Workers Free plan](/workers/platform/pricing/) allowing you to build AI agents with [Agents SDK](/agents), collaboration tools, or real-time applications like chat or multiplayer games.
10+
Durable Objects can now be used with zero commitment on the [Workers Free plan](/workers/platform/pricing/) allowing you to build AI agents with [Agents SDK](/agents), collaboration tools, and real-time applications like chat or multiplayer games.
1111

12-
Durable Objects let you build stateful, serverless applications with millions of tiny coordination instances that run your application code alongside, in the same thread!, as your durable storage. Each Durable Object can access its own SQLite database through a [Storage API](/durable-objects/best-practices/access-durable-objects-storage/).
12+
Durable Objects let you build stateful, serverless applications with millions of tiny coordination instances that run your application code alongside, in the same thread!, as your durable storage. Each Durable Object can access its own SQLite database through a [Storage API](/durable-objects/best-practices/access-durable-objects-storage/). A Durable Object class is defined in a Worker script encapulsating the Durable Object's behavior when accessed from a Worker. To try the code below, click the button:
13+
14+
[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/templates/tree/staging/TODO)
15+
16+
```js
17+
import { DurableObject } from "cloudflare:workers";
18+
19+
// Durable Object
20+
export class MyDurableObject extends DurableObject {
21+
...
22+
23+
async sayHello(name) {
24+
return `Hello, ${name}!`;
25+
}
26+
}
27+
28+
// Worker
29+
export default {
30+
async fetch(request, env) {
31+
// Every unique ID refers to an individual instance of the Durable Object class
32+
const id = env.MY_DURABLE_OBJECT.idFromName("foo");
33+
34+
// A stub is a client used to invoke methods on the Durable Object
35+
const stub = env.MY_DURABLE_OBJECT.get(id);
36+
37+
// Methods on the Durable Object are invoked via the stub
38+
const response = await stub.sayHello("world");
39+
40+
return response;
41+
},
42+
};
43+
```
1344

1445
Free plan [limits](/durable-objects/platform/pricing/) apply to Durable Objects compute and storage usage. Limits allow developers to build real-world applications, with every Worker request able to call a Durable Object on the free plan.
1546

1647
For more information, checkout:
1748
- [Documentation](/durable-objects/what-are-durable-objects/)
18-
- Zero-latency SQLite storinage in every Durable Object [blog](https://blog.cloudflare.com/sqlite-in-durable-objects/)
49+
- [Zero-latency SQLite storinage in every Durable Object blog](https://blog.cloudflare.com/sqlite-in-durable-objects/)

src/content/changelog/durable-objects/2025-04-07-sqlite-in-durable-objects-ga.mdx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,28 @@ description: SQLite-bakced Durable Objects are generally available.
44
products:
55
- durable-objects
66
- workers
7-
date: 2025-04-07T13:00:00Z
7+
date: 2025-04-07T06:00:00Z
88
---
99

10-
SQLite in Durable Objects is now generally available (GA). Since the [beta announcement](https://blog.cloudflare.com/sqlite-in-durable-objects/) in September 2024, we've added feature parity and robustness for the SQLite storage backed compared to the key-value (KV) storage backend that Durable Objects had had before then.
10+
SQLite in Durable Objects is now generally available (GA). Since the [public beta](https://blog.cloudflare.com/sqlite-in-durable-objects/) in September 2024, we've added feature parity and robustness for the SQLite storage backed compared to the preexisting key-value (KV) storage backend for Durable Objects.
1111

12-
SQLite-backed Durable Objects are recommended for all new Durable Object classes, using `new_sqlite_classes` [wrangler configuration](/durable-objects/best-practices/access-durable-objects-storage/#create-sqlite-backed-durable-object-class). Only SQLite-backed Durable Objects have access to Storage API's [SQL](/durable-objects/api/storage-api/#sql-api) and [point-in-time recovery](/durable-objects/api/storage-api/#pitr-point-in-time-recovery-api) methods, which provide flexible, relational data modeling, SQL access, and better data management.
12+
SQLite-backed Durable Objects are recommended for all new Durable Object classes, using `new_sqlite_classes` [wrangler configuration](/durable-objects/best-practices/access-durable-objects-storage/#create-sqlite-backed-durable-object-class). Only SQLite-backed Durable Objects have access to Storage API's [SQL](/durable-objects/api/storage-api/#sql-api) and [point-in-time recovery](/durable-objects/api/storage-api/#pitr-point-in-time-recovery-api) methods, which provide relational data modeling, SQL querying, and better data management.
13+
14+
```js
15+
export class MyDurableObject extends DurableObject {
16+
sql: SqlStorage
17+
constructor(ctx: DurableObjectState, env: Env) {
18+
super(ctx, env);
19+
this.sql = ctx.storage.sql;
20+
}
21+
22+
async sayHello() {
23+
let result = this.sql
24+
.exec("SELECT 'Hello, World!' as greeting")
25+
.one();
26+
return result.greeting;
27+
}
28+
}
29+
```
1330

1431
KV-backend Durable Objects remain for backwards compatibility, and a migration path from key-value storage to SQL storage for existing Durable Object classes will be offered in the future.

0 commit comments

Comments
 (0)