kas/memx
1
0
Fork
You've already forked memx
0
Memoize output from job execution
  • Python 91.2%
  • Shell 8.8%
Find a file
2026年06月19日 14:21:05 +02:00
contrib The bash prototype is no longer compatible with the Python implementation 2016年09月19日 18:37:25 +02:00
img Add identicon 2022年07月07日 09:22:19 +02:00
.gitignore Ignore JED's backup files 2015年10月04日 16:11:54 +02:00
LICENSE Initial commit 2015年10月04日 16:05:55 +02:00
memx Do not write to any state files unless buffer is non-empty 2026年06月19日 14:21:05 +02:00
README.md Update usage text 2016年09月21日 18:47:05 +02:00

memx

Memoize output from job execution, while preserving stdout, stderr and returncode: Subsequent runs will use the cached values from a previous run, unless TTL has been reached (by default, jobs are only run once).

Usage

Usage: memx [OPTIONS] -- COMMAND [ARG [ARG ...]]
Positional arguments:
 COMMAND command to run
 ARG optional argument(s) to command
Optional arguments:
 -h, --help show this help message and exit
 -v, --version show version information and exit
 -c, --copyright show copying policy and exit
 -f, --force re-run command no matter what
 -d [DIR], --dir [DIR]
 where to store cache data (default: ~/.cache)
 -t [TTL], --ttl [TTL]
 time before we re-run command (default: never)
 -x [CONTEXT], --context [CONTEXT]
 free form context
 --include-cwd [{yes,no,auto}]
 take $CWD into consideration (default: auto)

Requirements

Runs on Python 3 only (tested on Python 3.5.2).

Install

Drop memx in your $PATH.

Example(s)

$ memx -- date --utc '+%F %T %Z' # first run
2016年09月12日 16:22:44 UTC
$ echo $?
0
$ memx -- date --utc '+%F %T %Z' # subsequent run
2016年09月12日 16:22:44 UTC
$ echo $?
0

A more useful example could be to memoize the output from whois(1):

#!/bin/sh
# This is ~/.local/bin/whois
exec memx -- /usr/bin/whois "${@}"
# eof

😄