mongodb-driver v0.6.0 Mongo.Session.SessionPool View Source
A FIFO cache for sessions. To get a new session, call checkout
. This returns a new session or a cached session.
After running the operation call checkin(session)
to put the session into the FIFO cache for reuse.
The MongoDB specifications allows to generate the uuid from the client. That means, that we can just create server sessions and use them for logicial sessions. If they expire then we drop these sessions, otherwise we can reuse the server sessions.
Link to this section Summary
Functions
Checkin a used server session. It if is already expired, the server session is dropped. Otherwise the server session is cache for reuse, until it expires due of being cached all the time.
Return a server session. If the session timeout is not reached, then a cached server session is return for reuse. Otherwise a newly created server session is returned.
Returns a specification to start this module under a supervisor.
Handle a checkout call.
Handle a shutdown cast.
Initiaize an empty cache.
Starts the GenServer. The logical_session_timeout
is the timeout in minutes for each server session.
Link to this section Functions
checkin(pid, session)
View Source
checkin(GenServer.server(), Mongo.Session.ServerSession.t()) :: none()
checkin(GenServer.server(), Mongo.Session.ServerSession.t()) :: none()
Checkin a used server session. It if is already expired, the server session is dropped. Otherwise the server session is cache for reuse, until it expires due of being cached all the time.
checkout(pid)
View Source
checkout(GenServer.server()) :: Mongo.Session.ServerSession.t()
checkout(GenServer.server()) :: Mongo.Session.ServerSession.t()
Return a server session. If the session timeout is not reached, then a cached server session is return for reuse. Otherwise a newly created server session is returned.
child_spec(init_arg) View Source
Returns a specification to start this module under a supervisor.
See Supervisor
.
handle_call(msg, from, state) View Source
Handle a checkout call.
handle_cast(msg, state) View Source
Handle a shutdown cast.
init(state) View Source
Initiaize an empty cache.
start_link(top, logical_session_timeout)
View Source
start_link(GenServer.server(), integer()) :: GenServer.on_start()
start_link(GenServer.server(), integer()) :: GenServer.on_start()
Starts the GenServer. The logical_session_timeout
is the timeout in minutes for each server session.