Riptide.Store.Composite behaviour (riptide v0.5.0-beta10) View Source
This module provides a macro to define a store that splits up the data tree between various other stores. It is implemented via pattern matching paths that are being written or read and specifying which store to go to.
Usage
defmodule Todolist.Store do
use Riptide.Store.Composite
@memory {Riptide.Store.Memory, []}
@local {Riptide.Store.LMDB, directory: "data"}
@shared {Riptide.Store.Postgres, []}
def store(), do: [
@memory,
@local,
@shared,
]
# Any path starting with ["shared"] is saved in a shared postgres instance
def which_path(["shared" | _rest]), do: @shared
# Any path starting with ["tmp"] is kept only in memory
def which_path(["tmp" | _rest]), do: @memory
# Default catch all
def which_path(_), do: @local
end
Configuration
config :riptide,
store: %{
read: {Todolist.Store, []},
write: {Todolist.Store, []},
}
Link to this section Summary
Callbacks
List of stores to initialize that are used by this module.
For a given path, return which store to use. Take advantage of pattern matching to specify broad areas.
Link to this section Callbacks
Specs
stores() :: any()
List of stores to initialize that are used by this module.
Specs
For a given path, return which store to use. Take advantage of pattern matching to specify broad areas.