PathrockNetwork Gno Explorer
HomeBlocksTransactionsRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/p/moul/memo/v0

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
v0
Namespace
moul / memo
Files
3 (README)(gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/moul/memo/v0
gno
0.9

Files (3)

  • README.mdmarkdown
  • gnomod.tomltoml
  • memo.gnogno
README.mdPreviewRaw
# `gno.land/p/moul/memo/v0`

A simple memoization utility to cache function results, **backed by a B+ tree**
(`gno.land/p/nt/bptree`).

A B+ tree packs many entries per persisted node, so it costs materially less
storage and gas per cached entry than an AVL backing would.

```go
import "gno.land/p/moul/memo/v0"

m := memo.New()

// Cache expensive computation; subsequent calls with the same key
// return the cached result without re-running the function.
result := m.Memoize("key", func() any {
	return "computed-value"
})

m.Invalidate("key") // drop one entry
m.Clear()           // drop all entries
m.Size()            // number of cached entries
```

> ⚠️ **Gno usage:** storage updates only persist during transactions. Memoizing
> during queries/render will not persist and only wastes resources — use this in
> transaction-driven contexts.

**Caveats from the B+ tree backing:** it mutates in place (a copy-on-write AVL
backing would not), so do not Invalidate/add entries from inside a callback
iterating the same Memoizer, and do not copy a non-zero `Memoizer` by value.

<!-- BEGIN GNOCONTRACTS FOOTER (generated by `make readmes`; do not edit below) -->

---

Part of **[moul/gno-contracts](https://github.com/moul/gno-contracts)** — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

**Dependency graph:**

![gno.land/p/moul/memo/v0 dependency graph](https://raw.githubusercontent.com/moul/gno-contracts/main/_assets/gno.land/p/moul/memo/v0/deps.png)

> ⚠️ **Disclaimer:** provided as-is, without warranty; not security-audited. Full disclaimer: [DISCLAIMER](https://github.com/moul/gno-contracts/blob/main/DISCLAIMER.md).

<!-- END GNOCONTRACTS FOOTER -->

Functions

not supported for pure packages by the node (vm/qfuncs)

Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.