We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent adcf717 commit 886ec39Copy full SHA for 886ec39
src/lib/disk_cache/lmdb/disk_cache.ml
@@ -39,9 +39,13 @@ module Make (Data : Binable.S) = struct
39
Rw.get ~env db idx |> Option.value_exn
40
41
let put ({ env; db; counter; reusable_keys } : t) (x : Data.t) : id =
42
- (* TODO: we may reuse IDs by pulling them from the `garbage` hash set *)
43
- let idx = !counter in
44
- incr counter ;
+ let idx =
+ match Queue.dequeue reusable_keys with
+ | None ->
45
+ incr counter ; !counter - 1
46
+ | Some reused_key ->
47
+ reused_key
48
+ in
49
let res = { idx } in
50
(* When this reference is GC'd, delete the file. *)
51
Gc.Expert.add_finalizer_last_exn res (fun () ->
0 commit comments