class
Latch::Storage::Memory
- Latch::Storage::Memory
- Latch::Storage
- Reference
- Object
Overview
In-memory storage backend for testing purposes. Files are stored in a hash and are lost when the process exits. This is useful for testing without hitting the filesystem or network.
Latch.configure do |settings|
settings.storages["cache"] = Latch::Storage::Memory.new
settings.storages["store"] = Latch::Storage::Memory.new
end
Defined in:
latch/storage/memory.crConstructors
Instance Method Summary
- #base_url : String | Nil
-
#clear! : Nil
Clears out the store.
-
#delete(id : String) : Nil
Deletes the file at the given location.
-
#exists?(id : String) : Bool
Returns whether a file exists at the given location.
-
#open(id : String, **options) : IO
Opens the file at the given location and returns an IO for reading.
-
#size : Int32
Returns the number of stored files.
- #store : Hash(String, Bytes)
-
#upload(io : IO, id : String, **options) : Nil
Uploads an IO to the given location (id) in the storage.
-
#url(id : String, **options) : String
Returns the URL for accessing the file at the given location.
Instance methods inherited from class Latch::Storage
delete(id : String) : Nil
delete,
exists?(id : String) : Bool
exists?,
move(io : IO, id : String, **options) : Nilmove(file : Latch::StoredFile, id : String, **options) : Nil move, open(id : String, **options) : IO open, upload(io : IO, id : String, **options) : Nil upload, url(id : String, **options) : String url
Constructor Detail
Instance Method Detail
def open(id : String, **options) : IO
#
Opens the file at the given location and returns an IO for reading.
def upload(io : IO, id : String, **options) : Nil
#
Uploads an IO to the given location (id) in the storage.
def url(id : String, **options) : String
#
Returns the URL for accessing the file at the given location.