'\" t .\" Title: cmd_cachier .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.20 .\" Date: 2024-09-28 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" .TH "CMD_CACHIER" "1" "2024-09-28" "\ \&" "\ \&" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" cmd_cachier \- A caching service for your CLI commands using Redis. .SH "SYNOPSIS" .sp \fBcmd_cachier\fP \*(AqSUBCOMMAND\*(Aq [\*(AqYOUR_COMMAND\*(Aq]... .sp \fBcmd_cachier\fP [\*(AqYOUR_COMMAND\*(Aq]... .SH "PREREQUISITES" .sp Redis must be installed via your package manager of choice and must be in your PATH variable. Check if you can run \f(CRredis\-server\fP from the command line. .sp .B Example: Installation on MacOS (homebrew) .br .sp .if n .RS 4 .nf .fam C $ brew install redis .fam .fi .if n .RE .SH "DESCRIPTION" .sp \f(CRcmd_cachier\fP saves the stdout of your cli commands like \f(CRfind\fP or \f(CRfd\fP. If the command is not in the cache the command will execute in about the time it would take without \f(CRcmd_cachier\fP. The next time you use the command with \f(CRcmd_cachier\fP the console output should feel instantanious. .sp Also the lifetime of the cache is only as long as the machine runs. Meaning after a reboot it is cleared. .sp To keep commands refreshed, you can manually execute your command with the \f(CRsave\fP subcommand, or you could refresh it programmatically via systemd timers or crontab (see \f(CRman crontab\fP). .sp \f(CRcrontab\fP example: .sp Run: .sp .if n .RS 4 .nf .fam C $ crontab \-e .fam .fi .if n .RE .sp Add the line for an update every minute: .sp .if n .RS 4 .nf .fam C * * * * * cmd_cachier save YOUR_COMMAND .fam .fi .if n .RE .sp Or every 5 minutes: .sp .if n .RS 4 .nf .fam C */5 * * * * cmd_cachier save YOUR_COMMAND .fam .fi .if n .RE .SH "SUBCOMMANDS" .sp The following subcommands are available: .sp \f(CRsave\fP [YOUR_COMMAND]... .RS 4 Save command to database in any case. Will overwrite if already in db. .RE .sp \f(CRquery\fP [YOUR_COMMAND]... .RS 4 Try to query database. Returns empty string if not in db. .RE .sp \f(CRmemory\fP .RS 4 Display memory usage of saved commands. .RE .sp \f(CRinfo\fP .RS 4 Info about the Redis database. .RE .SH "EXAMPLES" .sp Cache list of files in \f(CR$HOME\fP: .sp .if n .RS 4 .nf .fam C $ cmd_cachier ls \-1 "$HOME" .fam .fi .if n .RE .sp Cache list of git projects: .sp .if n .RS 4 .nf .fam C $ cmd_cachier fd \-\-glob .git \-\-hidden \-\-type d \-\-max\-depth 6 \-\-prune .fam .fi .if n .RE .sp Additionally, remove the \f(CR.git\fP folders from the path: .sp .if n .RS 4 .nf .fam C $ cmd_cachier fd \-\-glob .git \-\-hidden \-\-type d \-\-max\-depth 6 \-\-prune | while read \-r line; do tmp="${line%/}"; echo "${tmp%/*}"; done .fam .fi .if n .RE .sp With \f(CRfzf\fP: .sp .if n .RS 4 .nf .fam C $ cmd_cachier fd . \-\-type d \-\-max\-depth 5 \-\-hidden "$HOME" | fzf .fam .fi .if n .RE .SH "TIPS AND TRICKS" .sp Alias \f(CRgp\fP to \f(CRcd\fP into a selected git project in the example above. .sp In your \f(CR.bashrc\fP: .sp .if n .RS 4 .nf .fam C alias gp=\*(Aqcd "$(cmd_cachier YOUR_SEARCH_COMMAND | fzf)"\*(Aq .fam .fi .if n .RE .sp Enforce refresh of the search on demand (alias with \f(CRgpup\fP): .sp .if n .RS 4 .nf .fam C alias gpup=\*(Aqcd "$(cmd_cachier save YOUR_SEARCH_COMMAND | fzf)"\*(Aq .fam .fi .if n .RE .SH "KNOWN BUGS AND ISSUES" .TS allbox tab(:); lt lt. T{ .sp Status T}:T{ .sp Bug T} T{ .sp Resolved in 0.3 T}:T{ .sp Every now and then a \f(CRdump.rdb\fP is created in the current directory. T} T{ .sp Resolved in 0.3.5 T}:T{ .sp No more memory overcommit message in stdout. It is now redirected to stderr so that you recieve the warning but does not interfere with the results. T} T{ .sp Open T}:T{ .sp Man page not availablein non\-system installs and cargo installs. (Only help page.) T} T{ .sp Open (planned for some 0.3.x or the next 0.4 release) T}:T{ .sp Can only use the "redis\-server" backend. Choosing "valkey" or "KeyDB" as backend is not supported yet. T} .TE .sp .SH "EXTERNAL LINKS" .sp .B manpages (mdoc macros) .br .URL "https://man.openbsd.org/mdoc.7" "" "" .sp .B manpages (man macros) .br .URL "https://manpages.ubuntu.com/manpages/trusty/man7/groff_man.7.html" "" "" .sp .B asciidoc/tor .br .URL "https://docs.asciidoctor.org/asciidoc/latest/syntax\-quick\-reference/" "" ""