Skip to content

Commit e34e07e

Browse files
committed
Adding extended methods to DO State page.
1 parent d713eff commit e34e07e

File tree

1 file changed

+17
-1
lines changed
  • src/content/docs/durable-objects/api

1 file changed

+17
-1
lines changed

src/content/docs/durable-objects/api/state.mdx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 5
66
---
77

8-
import { Tabs, TabItem, GlossaryTooltip } from "~/components";
8+
import { Tabs, TabItem, GlossaryTooltip, Type, MetaInfo } from "~/components";
99

1010
## Description
1111

@@ -267,6 +267,22 @@ export class MyDurableObject extends DurableObject {
267267

268268
- None.
269269

270+
## Extended methods
271+
272+
### `serializeAttachment`
273+
274+
- <code> serializeAttachment(value <Type text="any" />)</code>: <Type text="void" />
275+
276+
- Keeps a copy of `value` in memory (not on disk) to survive hibernation. The value can be any type supported by the [structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm), which is true of most types.
277+
278+
- If you modify `value` after calling this method, those changes will not be retained unless you call this method again. The serialized size of `value` is limited to 2,048 bytes, otherwise this method will throw an error. If you need larger values to survive hibernation, use the [Storage API](/durable-objects/api/storage-api/) and pass the corresponding key to this method so it can be retrieved later.
279+
280+
### `deserializeAttachment`
281+
282+
- `deserializeAttachment()`: <Type text='any' />
283+
284+
- Retrieves the most recent value passed to `serializeAttachment()`, or `null` if none exists.
285+
270286
## Properties
271287

272288
### `id`

0 commit comments

Comments
 (0)