class

DataDungeon::Storage

Inherits Reference < Object

Storage backend abstraction. file_path on an asset is an opaque key; a Storage implementation resolves that key to a real location. This keeps DataDungeon backend-agnostic: LocalStorage here, S3Storage (R2, Garage, MinIO, AWS) in data_dungeon/s3.

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
shared?

Whether other stores keep their objects here too, sharing each by its hash. DataDungeon can't know whether another store still uses an object, so it never deletes one from shared storage, and it writes an object even when it's there, so the object's date says when a store last relied on it. Clearing objects no store uses is for a program that reads every store's list (DB#object_keys).

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

Write bytes at the given key, creating any containers as needed. The content type is a hint for backends that serve objects themselves.

Source