wasm_storage_memory (wasm_storage v0.1.0)
View SourceA device held in memory.
The bytes live in a public ETS table as fixed-size blocks, so any process can
read the device: a test can kill the process that was using it and open it
again, the way a restart would reopen a file. The device is volatile:
sync/2 succeeds, and the data lasts as long as the table.
Two ways to get one:
%% A device of its own, deleted when the handle closes or its owner exits:
{ok, H} = wasm_storage:open({wasm_storage_memory, new}, #{}).
%% A device that outlives its handles, owned by the calling process:
{ok, Dev} = wasm_storage_memory:new(#{}),
{ok, H1} = wasm_storage:open({wasm_storage_memory, Dev}, #{}),
ok = wasm_storage:close(H1),
{ok, H2} = wasm_storage:open({wasm_storage_memory, Dev}, #{}).Options of new/1 (and of open/2 with new):
block_size: bytes per block, a power of two, default 4096.max_size: writes or resizes past this many bytes fail withenospc. Defaultinfinity.
Blocks never written read as zeros and take no memory.
Summary
Functions
The whole content of a device, for tests and crash images.
A new device holding Bin.
Create a device owned by the calling process.