Urgent.News

What's breaking now, across thousands of outlets.

Tech

Once: Cache CLI Commands

The "once" CLI tool allows you to execute a command once and reuse its output for a specified period. When you run a command with "once," it executes the command in your current directory and stores the standard output in memory within a background daemon. Subsequent calls to the same command, directory, and tenant key within 8 hours will retrieve the cached output instead of re-running the command. The daemon automatically stops when all cached entries expire.

Typically, "once" is used to read secrets like those from 1Password without repeatedly authenticating with a fingerprint. By running "once" once, subsequent calls within an 8-hour window won't require the fingerprint for authentication.

To set up "once," you can create a configuration file named "mise.local.toml" and specify options and commands in it. The tool supports various formatting options for the --until flag to set the expiration time of the cached entry. The default working directory is included in the cache key, but you can exclude it using the --no-dir flag for commands with directory-independent outputs.

The cache key is generated using an HMAC-SHA256 hash of the tenant key, working directory, command, and arguments. The tenant key serves as a namespace and is not meant to be kept secret. Multiple terminals can share the same cache by using a fixed tenant key.

The daemon runs in a secure, user-specific directory with restricted permissions, ensuring that other users cannot access the cache. The cache is stored in a socket accessible only to the user running "once." By default, the working directory is part of the cache key, but you can use the --no-dir flag for commands with directory-independent outputs.

Written by urgent.news from Hacker News's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at github.com →

More in Tech

Virtual PLC Lab: Ladder Logic Control of a Filling Tank with Factory I/O and OpenPLC over Modbus TCP

I wanted to learn PLC programming, but there was one obvious problem: I don't own a PLC, a tank, valves, or a panel with buttons. Buying that hardware just to practice ladder logic isn't realistic.

  • Author creates virtual PLC lab with 3D process simulator and soft PLC
  • Modbus TCP enables communication between simulator and PLC
  • Ladder logic controls tank operations based on button presses and time intervals

More from Friday 9 October →