https://github.com/haya14busa/cachecmd
cache command!
https://github.com/haya14busa/cachecmd
cache cli
Last synced: about 1 year ago
JSON representation
cache command!
- Host: GitHub
- URL: https://github.com/haya14busa/cachecmd
- Owner: haya14busa
- License: mit
- Created: 2018-05-03T15:45:55.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-05-11T09:34:47.000Z (about 4 years ago)
- Last Synced: 2025-03-30T20:42:55.249Z (about 1 year ago)
- Topics: cache, cli
- Language: Go
- Homepage:
- Size: 25.4 KB
- Stars: 27
- Watchers: 4
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cachecmd
[](https://travis-ci.org/haya14busa/cachecmd)
[](https://codecov.io/gh/haya14busa/cachecmd)
[](https://goreportcard.com/report/github.com/haya14busa/cachecmd)
[](LICENSE)
cachecmd runs a given command and caches the result of the command.
Return cached result instead if cache found.
## Installation
```shell
go install github.com/haya14busa/cachecmd/cmd/cachecmd@latest
```
## Example
```shell
$ cachecmd -ttl=10s date +%S
14 # First run
$ sleep 5s
$ cachecmd -ttl=10s date +%S
14 # Read from cache
$ sleep 5s
$ cachecmd -ttl=10s date +%S
24 # cache is expired. Run command again and update cache.
# Force update: set -ttl=0
$ cachecmd -ttl=0 date +%S
# TTL is 10 min. Return cache result immediately from cache and update cache
# in background for every run.
$ cachecmd -ttl=10m -async sh -c 'date +%s; sleep 3s'
# Cache result by current directory.
$ cachecmd -ttl=10m -key="$(pwd)" go list ./...
# https://github.com/github/hub
$ cachecmd -ttl=10m -key="$(pwd)" -async hub issue
```
## :bird: Author
haya14busa (https://github.com/haya14busa)