-
Hi, Is there a simple way to not cache the function results if the function returns with an exit code > 0? Use case, a function doing a network operation and cache it for 24h. If unluckily there is a network outage the first time the function is called, then every subsequent calls will return the same error. I've quickly tried with the new Thanks Small example: #!/usr/bin/env bash
set -euo pipefail
source bash-cache.sh
function func1() {
date
## Simulate a transient error like a temporary network failure
ret=$((($RANDOM)%2))
echo "return $ret"
return $ret
} && bc::cache func1 24h 24h
func1 || echo "Failed 1"
# Try to autorecover
func1 || { echo "Failed 2 -> retry"; bc::force::func1; } || echo "Still failing"
func1 || echo "Failed 3"
|
Beta Was this translation helpful? Give feedback.
Answered by
kumy
Oct 28, 2022
Replies: 1 comment 1 reply
-
🤦♂️ Seems a bug is already open for that #25 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
dimo414
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🤦♂️ Seems a bug is already open for that #25