Skip to content

Commit

Permalink
Add blackhole storage
Browse files Browse the repository at this point in the history
This can be useful as a storage in cases when you do not need or want to
store cached images anywhere, for example because you have CDN in front
of the Imager and it is caching the requests.
  • Loading branch information
hauleth committed Oct 3, 2018
1 parent e514c54 commit a1d3fa2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/imager/config/store_transform.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ defmodule Imager.Config.StoreTransform do
defp get_cache(%{cache: values}), do: parse(values)
defp get_cache(values), do: parse(values)

defp parse(%{type: type} = values) when type in ~w(S3 Local) do
defp parse(%{type: type} = values) when type in ~w(S3 Local Blackhole) do
module = Module.safe_concat(Imager.Store, type)
opts = Keyword.new(Map.get(values, :options, []))

Expand Down
12 changes: 12 additions & 0 deletions lib/imager/store/blackhole.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
defmodule Imager.Store.Blackhole do
@behaviour Imager.Store

@moduledoc """
`/dev/null` of the stores. All writes will discard data and all reads
will automatically fail.
"""

def retrieve(_path, _ops), do: :error

def store(_path, _mime, stream, _opts), do: stream
end

0 comments on commit a1d3fa2

Please sign in to comment.