class

DataDungeon::LocalStorage

Inherits DataDungeon::Storage < Reference < Object

Local filesystem storage rooted at a directory. Keys are relative paths under the root, e.g. "venue/ab/abcd….webp".

Constructors

new(root : String, *, shared : Bool = false)
Source

Instance methods

delete(key : String) : Nil

Remove the object at the given key (no-op if absent).

Source
exists?(key : String) : Bool

Whether an object exists at the given key.

Source
list_keys

Enumerate every object key currently in the backend. Used by the consistency sweep to find objects with no owning row. May be expensive on large object stores; intended for maintenance, not the hot path.

Source
local?

Whether checking an object costs a file-system call rather than a network round trip. Lookups only confirm that a record's object still exists when it does; for remote storage, check_consistency finds drift.

Source
open(key : String, & : IO -> ) : Nil

Stream the object at the given key: the block gets an IO over its bytes. This default reads the whole object; adapters that can stream override it.

Source
read(key : String) : Bytes

Read the bytes stored at the given key.

Source
resolve(key : String) : String

Resolve a key to a usable location — a local absolute path here, a URL for object stores.

Source
root
Source
write(key : String, bytes : Bytes, content_type : String | Nil = nil) : Nil

Writes to a temporary sibling, then renames it into place, so a crash never leaves a truncated object at the key. DB#store skips writing a content-addressed key that already exists, so a partial object there would otherwise be permanent.

Source