package granary

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

Module Granary_storage.FreelistSource

In-memory freelist. Tracks freed pages and when they can be reused. A page freed at txn_id T becomes reusable when min_safe_txn_id > T (i.e. freed_at_txn_id < min_safe_txn_id). Pure — no I/O, no Lwt.

Sourcetype t
Sourceval pp : Format.formatter -> t -> unit

Pretty-print the freelist's entry count.

Sourceval empty : t

The empty freelist (no freed pages).

Sourceval add : t -> page_id:int32 -> freed_at_txn_id:int64 -> t

Add a page to the free set. freed_at_txn_id: the txn_id of the transaction that freed the page.

Sourceval pop : t -> min_safe_txn_id:int64 -> (int32 * t) option

Pop a reusable page. A page is reusable if freed_at_txn_id < min_safe_txn_id. Returns (page_id, updated_t) or None if no reusable page is available. Picks the page with the lowest freed_at_txn_id first (oldest freed first).

Sourceval to_list : t -> (int32 * int64) list

All entries in the freelist — for serialisation to Freelist pages.

Sourceval of_list : (int32 * int64) list -> t

Reconstruct from a list (deserialised from Freelist pages).

Sourceval size : t -> int

Number of entries in the freelist.

Sourceval reusable_count : t -> min_safe_txn_id:int64 -> int

Reusable count: number of entries with freed_at_txn_id < min_safe_txn_id.