package tezos-protocol-013-PtJakart

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

Frequently used data should be kept in memory and persisted along a chain of blocks. The caching mechanism allows the economic protocol to declare such data and to rely on a Least Recently Used strategy to keep the cache size under a fixed limit.

Take a look at Environment_cache and Environment_context for additional implementation details about the protocol cache.

The protocol has two main kinds of interaction with the cache:

1. It is responsible for setting up the cache with appropriate parameter values and callbacks. It must also compute cache nonces to give the shell enough information to properly synchronize the in-memory cache with the block contexts and protocol upgrades. A typical place where this happens is Apply. This aspect must be implemented using Cache.Admin.

2. It can exploit the cache to retrieve, to insert, and to update cached values from the in-memory cache. The basic idea is to avoid recomputing values from scratch at each block when they are frequently used. Script_cache is an example of such usage. This aspect must be implemented using Cache.Interface.

type size = int

Size for subcaches and values of the cache.

type index = int

Index type to index caches.

module Admin : sig ... end

The following module acts on the whole cache, not on a specific sub-cache, unlike Interface. It is used to administrate the protocol cache, e.g., to maintain the cache in a consistent state with respect to the chain. This module is typically used by low-level layers of the protocol and by the shell.

type namespace = private string

A client uses a unique namespace (represented as a string without '@') to avoid collision with the keys of other clients.

val create_namespace : string -> namespace

create_namespace str creates a valid namespace from str

type identifier = string

A key is fully determined by a namespace and an identifier.

module type CLIENT = sig ... end

To use the cache, a client must implement the CLIENT interface.

module type INTERFACE = sig ... end

An INTERFACE to the subcache where keys live in a given namespace.

val register_exn : (module CLIENT with type cached_value = 'a) -> (module INTERFACE with type cached_value = 'a)

register_exn client produces an Interface specific to a given client. This function can fail if client does not respect the invariant declared in the documentation of CLIENT.

OCaml

Innovation. Community. Security.