package tezos-protocol-012-Psithaca
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=43723d096307603703a1a89ed1b2eb202b365f5e7824b96b0cbf813b343a6cf7
sha512=b2a637f2e965000d3d49ad85277ca24d6cb07a1a7cf2bc69d296d8b03ad78c3eaa8e21e94b9162e62c2e11649cd03bc845b2a3dafe623b91065df69d47dc8e4f
doc/tezos-protocol-012-Psithaca.raw/Tezos_raw_protocol_012_Psithaca/Cache_repr/index.html
Module Tezos_raw_protocol_012_Psithaca.Cache_repr
Source
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
.
Size for subcaches and values of the cache.
Index type to index caches.
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.
A client uses a unique namespace (represented as a string without '@') to avoid collision with the keys of other clients.
create_namespace str
creates a valid namespace from str
A key is fully determined by a namespace and an identifier.
To use the cache, a client must implement the CLIENT
interface.
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
.