filememo

package
v0.1.4621 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package filememo keeps what was parsed from a file until the file changes, so a page that asks many times over reads it once.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DropKind

func DropKind(kind string)

DropKind lets go of what was kept of every file read as kind: the next Read of one reads and parses it again.

func Forget added in v0.1.908

func Forget()

Forget has every file looked at again on its next read: magpie wrote one.

func Gen added in v0.1.1291

func Gen() uint64

Gen is moved on by every Forget: what is built from files read here, and kept past one read, is built again when it moved.

func Hold added in v0.1.908

func Hold() (release func())

Hold has a file found unchanged not looked at again, for a request that only reads, until release is called or a second has gone by: the GUI's state looked at each agent's files hundreds of times over, a few thousand looks at the disk that a slow one (a Mac's antivirus looking at each) made seconds. A write meanwhile (Forget) has them looked at.

func Look added in v0.1.1201

func Look(path string)

Look has the file at path looked at on its next read, even while a request holds what was read (Hold): another magpie may have written it, which Forget, moved on by this one's writes alone, can't know of.

func OthersEvery added in v0.1.1549

func OthersEvery() time.Duration

OthersEvery is how often a loop that follows magpie's files (Written) looks for what another process (the CLI, a second magpie) wrote: every few seconds, or, while Watch is told of their changes, only now and then for one it missed (#3185: the looks woke an idle magpie on each beat, a dozen times every five seconds).

func Read

func Read[T any](kind, path string, parse func([]byte) (T, error)) (T, error)

Read is parse of the file at path, from what it gave last time when the file has the same size and time as then (and, written just now, the same bytes). kind tells apart two parses of one file. What it returns is shared: the caller must not change it.

func ReadNow added in v0.1.1825

func ReadNow[T any](kind, path string, parse func([]byte) (T, error)) (T, error)

ReadNow is Read with the file looked at even while a request holds what was read (Hold): for bytes a write is made from, which a write another process made inside the held second would otherwise be lost under.

func Watch added in v0.1.1564

func Watch(ctx context.Context, paths ...string)

Watch has a change another process makes to one of paths seen at once, as a write of magpie's own is (Written), until ctx ends. Their folders are watched, not the files: a file written whole is a new one put in its place. Where the folders can't be watched, the loops go on looking every few seconds.

func Written added in v0.1.1549

func Written() <-chan struct{}

Written is closed by the next write magpie makes (Forget), or by another process's that Watch is told of: a loop that follows magpie's files waits on it, and looks at them only every so often (OthersEvery) for what another process wrote, rather than polling each second for its own writes too (#3185: those polls woke an idle magpie ~12 times a second). No loop may take it inside a synctest bubble: a channel made there is the bubble's and outlives it, and its next use from outside the bubble (a write's close, a loop's select) is fatal, in whichever test comes next.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL