Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v0 source realm

Readme View source

LRU Cache

⚠️ Experimental — generated with no human supervision. This realm was produced automatically by an MCP-driven agent to exercise the gno MCP server and tooling, and to generate test content for gno compilers, linters and formatters. Not audited. Not for production. Full context & folder README: r/moul/x/daily


A fixed-capacity (8) least-recently-used cache realm — a port of the classic LRU. Put inserts or updates an entry and marks it most-recently-used, evicting the least-recently-used entry when capacity is exceeded. Get returns a value, bumps its recency, and records a hit or a miss. Render shows the entries in MRU→LRU order alongside the capacity and hit/miss stats.

Realm path: gno.land/r/REPLACE_ADDR/lru

Example calls

# insert / update entries (marks them most-recently-used)
Put("a", "1")
Put("b", "2")

# read a value (counts a hit, bumps recency)
Get("a")   # -> "1", true

# read a missing key (counts a miss)
Get("zzz") # -> "", false

# clear everything
Reset()

# view state (MRU→LRU order + stats)
Render("")

Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

🧪 Highly experimental — potentially vibe-coded. Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: DISCLAIMER.

Functions 4

func Get

crossing Action
1func Get(cur realm, key string) (string, bool)
source

Get returns the value for key and marks it most-recently-used. It records a hit or a miss. The returned bool reports whether the key was present.

func Put

crossing Action
1func Put(cur realm, key string, value string)
source

Put inserts or updates key with value and marks it most-recently-used. Evicts the least-recently-used entry if capacity is exceeded.

func Render

1func Render(path string) string
source

Render displays the cache contents in MRU->LRU order with stats.

Imports 3

  • chain stdlib
  • strconv stdlib
  • strings stdlib

Source Files 3