package index

  1. Overview
  2. Docs
A platform-agnostic multi-level index for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

index-1.6.0.tbz
sha256=5e0c1f6cbd6e485cbbf2344c8f76de8a7869155355ae6edd5550c88da0661594
sha512=613fa206d1124b34259421f4ea978ce4e9404d78af3a687c1e406d88a5d481bd51465fafae58da9eb3e6a0b5408118b8a7dfe1fbb05ce8fed4b8b0a572beb99b

doc/src/index/cache.ml.html

Source file cache.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
(* The MIT License

   Copyright (c) 2019 Craig Ferguson <craig@tarides.com>
                      Thomas Gazagnaire <thomas@tarides.com>
                      Ioana Cristescu <ioana@tarides.com>
                      Clément Pascutto <clement@tarides.com>

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software and associated documentation files (the "Software"), to deal
   in the Software without restriction, including without limitation the rights
   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   copies of the Software, and to permit persons to whom the Software is
   furnished to do so, subject to the following conditions:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software. *)

open! Import

module type S = sig
  type ('k, 'v) t
  (** A cache of values of type ['v], indexed by keys of type ['k]. *)

  val create : unit -> (_, _) t
  val add : ('k, 'v) t -> 'k -> 'v -> unit
  val find : ('k, 'v) t -> 'k -> 'v option
  val remove : ('k, _) t -> 'k -> unit
end

(** Cache implementation that always misses. *)
module Noop : S = struct
  type (_, _) t = unit

  let create () = ()
  let add () _ _ = ()
  let find () _ = None
  let remove () _ = ()
end

(** Cache implementation that always finds previously-added values, and grows
    indefinitely. *)
module Unbounded : S = struct
  include Hashtbl

  let create () = create 0
  let find = find_opt
end