package caqti

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

Module Request_cache.MakeSource

Parameters

module Elt : Lru.Weighted

Signature

Sourcetype elt = Elt.t
Sourcetype t
Sourceval create : ?dynamic_capacity:int -> Caqti_template.Dialect.t -> t

create dialect creates a cache of prepared queries for requests specialized for dialect.

  • parameter dynamic_capacity

    is the sum weight of elements of the LRU used for dynamic requests below which trim will not attempt to release anything.

Sourceval find_and_promote : t -> ('a, 'b, 'm) Caqti_template.Request.t -> elt option

find_and_promote cache request promotes and returns the data associated with request in cache, if any.

Sourceval add : t -> ('a, 'b, 'm) Caqti_template.Request.t -> elt -> unit

Given the hard precondition that request is not bound in cache, as verified by find_and_promote, add cache request data binds it to data.

Sourceval remove_and_discard : t -> ('a, 'b, 'm) Caqti_template.Request.t -> unit

remove_and_discard cache request removes the binding for request from cache. The caller is assumed to have just extracted the element with find_and_promote and is resposible for releasing related resources.

Sourceval deallocate : t -> ('a, 'b, 'm) Caqti_template.Request.t -> (elt * (unit -> unit)) option

deallocate request returns the entry for request, if any, along with a function to remove it from the cache.

Sourceval iter : (elt -> unit) -> t -> unit

iter f cache calls f on each element of cache.

Sourceval elements : t -> elt list

elements cache is an arbitrarily ordered list of all elements, whether associated with a static or dynamic request.

Sourceval trim : ?max_promote_count:int -> t -> elt list * (unit -> unit)

trim ?promote_count cache carrious out some work trimming elements from the dynamic LRU cache. The call promotes up to max_promote_count elements, which are alive according to the garbage collector, and stop at the next one. It is up to the caller to free any resources associated with the returned elements.

Sourceval clear_and_discard : t -> unit

clear cache removes all entries form cache. Elements are not returned, since this function may be used after a connection reset which invalidates the cached resources, but can be requested by calling elements first.

Sourceval dynamic_weight : t -> int
OCaml

Innovation. Community. Security.