wasm_storage_file (wasm_storage v0.1.0)
View SourceA device backed by a file, through the standard file module.
The file is opened in raw mode: calls go straight to the file driver
without a server process in between, and only the process that opened the
handle may use it. No native code beyond OTP's own is involved.
{ok, H} = wasm_storage:open({wasm_storage_file, "/var/db/data.redb"},
#{create => true}).Options:
create:false(the default) opens an existing file;truecreates it when missing;exclusivefails witheexistwhen it exists.access:read_write(the default) orread. A read-only handle refuses writes, resizes and syncs withebadf.sync:true(the default).falsemakessync/2returnokwithout syncing and makesinfo/1report the device asvolatile. It exists for benchmarks that measure everything but the disk; never use it for data you want back.
sync(H, data) calls file:datasync/1, sync(H, full) calls file:sync/1.
What those reach on each platform is in
the storage contract.
Summary
Functions
The device and inode of the file, so that two paths of one file conflict in
wasm_storage_owner. With create the file is created first, so that the
identity exists before anyone opens it.