nova_session behaviour (nova v0.14.3)

View Source

All kind of operations on sessions is handled by the nova_session-module. The module also presents a behaviour that can be used to create customized backends for the session-data.

Summary

Callbacks

delete_value/1

-callback delete_value(SessionId) -> ok | {error, Reason :: atom()} when SessionId :: binary().

delete_value/2

-callback delete_value(SessionId, Key) -> ok | {error, Reason :: atom()}
                          when SessionId :: binary(), Key :: binary().

get_value/2

-callback get_value(SessionId, Key) -> {ok, Value :: any()} | {error, Reason :: atom()}
                       when SessionId :: binary(), Key :: binary().

set_value/3

-callback set_value(SessionId, Key, Value) -> ok | {error, Reason :: atom()}
                       when SessionId :: binary(), Key :: binary(), Value :: binary().

start_link/0

(optional)
-callback start_link() ->
                        {ok, Pid :: pid()} |
                        {error, Error :: {already_started, pid()}} |
                        {error, Error :: term()} |
                        ignore.

Functions

delete(Req)

-spec delete(Req :: cowboy_req:req()) -> {ok, Req :: cowboy_req:req()} | {error, Reason :: atom()}.

delete(Req, Key)

-spec delete(Req :: cowboy_req:req(), Key :: binary()) ->
                {ok, Req :: cowboy_req:req()} | {error, Reason :: atom()} | no_return().

generate_session_id()

get(Req, Key)

-spec get(Req :: cowboy_req:req(), Key :: binary()) ->
             {ok, Value :: binary()} | {error, Reason :: atom()} | no_return().

set(Req, Key, Value)

-spec set(Req :: cowboy_req:req(), Key :: binary(), Value :: binary()) ->
             ok | {error, Reason :: atom()} | no_return().