View Source Mongo.Session.SessionPool (mongodb-driver v1.4.1)
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.
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.
Types
@type session_pool() :: %{ :pool_size => any(), :queue => [Mongo.Session.ServerSession.t()], :timeout => any(), optional(any()) => any() }
Functions
@spec checkin(session_pool(), Mongo.Session.ServerSession.t()) :: session_pool()
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.
@spec checkout(session_pool()) :: {Mongo.Session.ServerSession.t(), session_pool()}
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.