class

Latch::Storage::Memory

Inherits Latch::Storage / Reference / Object

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

Constructors

new(base_url : String | Nil = nil)
Source

Instance methods

base_url
Source
clear!

Clears out the store.

Source
delete(id : String) : Nil

Deletes the file at the given location.

Source
exists?(id : String) : Bool

Returns whether a file exists at the given location.

Source
open(id : String, **options) : IO

Opens the file at the given location and returns an IO for reading.

Source
size

Returns the number of stored files.

Source
store
Source
upload(io : IO, id : String, **options) : Nil

Uploads an IO to the given location (id) in the storage.

Source
url(id : String, **options) : String

Returns the URL for accessing the file at the given location.

Source