package ocsigenserver
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=acb09f06430cb8eefd83a849af6450af
sha512=f2c5111a02989572a19706ca5238d3740c4c06d97b0e1791ae0e06665666574ada94421d10edee636042984ab9df6357b4febbb4edc34b01e72619027b95bfec
doc/ocsigenserver.baselib/Ocsigen_cache/Dlist/index.html
Module Ocsigen_cache.Dlist
Doubly-linked lists with maximum number of entries, and (possibly) limited lifespan for entries.
val create : ?timer:float -> int -> 'a tCreate a dlist. It takes the maximum length of the list as parameter. The optional ?timer parameter sets a maximum lifetime for elements (in seconds).
val add : 'a -> 'a t -> 'a optionAdds an element to the list, and possibly returns the element that has been removed if the maximum size was exceeded.
val remove : 'a node -> unitRemoves an element from its list. If it is not in a list, it does nothing. If it is in a list, it calls the finaliser, then removes the element. If the finaliser fails with an exception, the element is removed and the exception is raised again.
val up : 'a node -> unitRemoves the element from its list without finalising, then adds it as newest.
val size : 'a t -> intval maxsize : 'a t -> intval value : 'a node -> 'aval get_timer : 'a t -> float optionreturns the timer of the Dlist
val remove_n_oldest : 'a t -> int -> 'a listremove the n oldest values (or less if the list is not long enough) ; returns the list of removed values
val fold : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'bfold over the elements from the cache starting from the newest to the oldest
val fold_back : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'bfold over the elements from the cache starting from the oldest to the newest
val lwt_fold : ('b -> 'a -> 'b Lwt.t) -> 'b -> 'a t -> 'b Lwt.tlwt version of fold
val lwt_fold_back : ('b -> 'a -> 'b Lwt.t) -> 'b -> 'a t -> 'b Lwt.tlwt version of fold_back
Move a node from one dlist to another one, without finalizing. If one value is removed from the destination list (because its maximum size is reached), it is returned (after finalisation).
val set_maxsize : 'a t -> int -> 'a listchange the maximum size ; returns the list of removed values, if any.
set a function to be called automatically on a piece of data just before it disappears from the list (either by explicit removal or because the maximum size is exceeded)
set a function to be called automatically on a piece of data just after it disappears from the list (either by explicit removal or because the maximum size is exceeded)