sessioncache

package
v3.0.0-rc76 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 21 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 sessioncache provide session cache for functions

The processes of a session share its cache: the commands an action runs, and the actions a multi-object command runs on a node, read the outputs the others cached. A process using the cache holds a shared fcntl lock on the session's users file while it runs, and the cache is purged by the last one exiting only: one exiting first does not remove the cache under the others.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clear

func Clear(sig string) error

Clear removes the current cached output

The process uses the cache to clear it, as to read it: it holds the shared lock of the users file before it opens the lock file of the cache file, so a purge or a sweep does not remove the lock file under it. A use failing, the output is cleared still, for the other processes of the session not to read it.

func Output

func Output(o fcache.Outputter, sig string) (out []byte, err error)

Output manage output session function cache

A cache file removed while it is read or written, as by a process of the session purging it, is a cache miss: the output is the one of the command, run once. A command run already, its output not cached, is not run again: its output, or its error, is the answer.

func PurgeCache

func PurgeCache() error

PurgeCache purges the session cache when no other process of the session uses it, and releases the use of this process. The last process using it purges it: the cache directory, and the lock files of its cache files, which a lock released keeps.

func Sweep

func Sweep(maxAge time.Duration, log *plog.Logger) (removed int, err error)

Sweep removes what the processes of the sessions left behind, killed, crashed or exiting early, not purging it: the session cache directories of Paths.Cache, and the lock files of their cache files, "<session id>-out- <key>" in Paths.Lock, of the sessions no process changed for maxAge and no process uses. removed counts the directories and the lock files.

Only the direct children of Paths.Cache named as a session cache are considered, a session id or a session id renamed for its purge, and the direct regular files of Paths.Lock named as a lock file of a session: the other entries, as the ageing cache, belong to someone else. Symlinks are left alone.

The age of a session is the one of the newest of its cache directory, the direct entries of the directory, and its lock files: a cache file written in place or the users file changes their own modification time, not the one of the directory, and a process locking a lock file writes to it.

The directory and the lock files of a session are removed under the exclusive lock of the users file of the session, granted when no process of the session holds its shared lock, which a process holds as long as it uses the cache, before it opens a lock file: no process waits on a lock file removed, nor locks the file removed while another locks a new one at its path. The directory is renamed away under the lock, as PurgeCache does, before its removal. The session of this process is left alone, as a fcntl lock of this same process would not protect it.

The errors of a session are logged and do not stop the sweep: the error returned is the one of the read of Paths.Cache or Paths.Lock.

Types

This section is empty.

Jump to

Keyboard shortcuts

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