Skip to content

Commit

Permalink
Add examples. (#1681)
Browse files Browse the repository at this point in the history
  • Loading branch information
floitsch authored Jun 29, 2023
1 parent 8f76fd8 commit 0d8c937
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/system/storage.toit
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@
/**
User-space side of the service API for key-value storage.
# Examples
Store and read a value in a RAM-backed bucket. The used memory
survives deep sleep, but not a restart of the device due to
a reset or power loss.
```
import system.storage
main:
bucket := storage.Bucket.open --ram "my-bucket"
bucket["key"] = "value"
print bucket["key"]
```
Use a 128 byte region in flash to store binary data.
```
import system.storage
main:
region := storage.Region.open --flash "my-region" --capacity=128
region.write --from=0 #[0x12, 0x34]
```
*/

import encoding.tison
Expand Down

0 comments on commit 0d8c937

Please sign in to comment.