Library
Module
Module type
Parameter
Class
Class type
PostgreSQL backend using the Session.S.Now
signature.
The default expiry period is one week. The code expects the following table and index to be in place:
CREATE TABLE IF NOT EXISTS session ( session_key char(40), expire_date timestamp (2) with time zone, session_data text ); CREATE INDEX session_key_idx ON session (session_key);
include Session.S.Now
with type t = Postgresql.connection
and type key = string
and type value = string
and type period = int64
default_period t
returns default period after which session keys will expire. Depending on the backend, this value may vary over time.
generate ?expiry ?value t
will allocate a new session in the backend t
and return its associated key
. The session will expire expiry
seconds from now, defaulting to default_period t
if one is not explicitly specified.
The key should be unique, though it may not be in order to allow implementations that use randomness or hashing to conform to this interface.
clear t key
removes key
from the backend t
. The backend may choose to persist the session value beyond this call, but any subsequent calls operations involving key
should behave as if key
is not present in the backend.
val get : t -> key -> (value * period, Session.S.error) Stdlib.result
get t key
returns the session value, if present and unexpired, together with its expiry period as of now.
val connect :
?host:string ->
?hostaddr:string ->
?port:string ->
?dbname:string ->
?user:string ->
?password:string ->
?options:string ->
?tty:string ->
?requiressl:string ->
?conninfo:string ->
?startonly:bool ->
unit ->
t
Create a connection to a postgresql database.
This is an alias for the connection constructor. If you have an existing connection to a database with the appropriate tables set up, you are more than welcome to use it.