package caqti

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Pool configuration.

type _ key
type t

Construction and Generic Operations

val create : ?max_size:int -> ?max_idle_size:int -> ?max_idle_age:Mtime.Span.t option -> ?max_use_count:int option -> unit -> t

Creates a configuration for the implementation of Caqti_pool_sig.S. The main arguments populate the configuration with the corresponding settings, which are explaind in Configuration Keys.

val default : t

The configuration object with no setting, which gives the built-in defaults. Alternatively, use default_from_env for a configuration based on environment variables.

val default_from_env : unit -> t

default_from_env () is a configuration constructed from environment variables of the form CAQTI_POOL_<suffix>, with the upper-cased names of the configuration keys substituted for <suffix>.

val merge_left : t -> t -> t

merge_left cL cR is the configuration cL with missing settings populated by the corresponding present settings from cR.

val get : 'a key -> t -> 'a option

get key config is the value of key in config or None if unset.

val set : 'a key -> 'a -> t -> t

set key value config is config with key set to value regardless of any previous mapping.

val unset : 'a key -> t -> t

unset key config is config without its mapping for key if any.

Configuration Keys

val max_size : int key

The maximum number of open connections associated with the pool. When this limit is hit, an attempt to use the pool will block until a connection becomes available. The value must be at least one. If the selected driver does not support concurrent connections, the value 1 is assumed.

val max_idle_size : int key

The maximum number of idle connections to put into the pool for reuse. Must be between 0 and max_size. If you set this, you must also ensure max_size is set so that the combination is valid. Defaults to max_size. For drivers which does not support concurrent connections, the value will clipped to a maximum of 1.

val max_idle_age : Mtime.Span.t option key

The maximum age of idle connections before they are scheduled to be disconnected and removed from the pool, or None for no limit. Where possible, a timer will be used to trigger the cleanup. For the caqti.blocking library, the cleanup will only be done opportunistically when the pool is used.

val max_use_count : int option key

The maximum number of times a pooled connection is reused, or None for no limit. The default is currently 100, but may be changed in the future based on real-world experience. The reason this setting was introduced is that we have seen state being retained on the server side.

OCaml

Innovation. Community. Security.