2016-04-19 10:37:39 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
. $(dirname $0)/preload.sh
|
|
|
|
|
|
|
|
help() {
|
|
|
|
zaf_err "$0 seconds cmd..."
|
|
|
|
}
|
|
|
|
|
|
|
|
seconds=$1
|
|
|
|
shift
|
|
|
|
[ -z "$*" ] && help
|
|
|
|
|
2016-04-21 15:29:48 +02:00
|
|
|
zaf_trc "zafcache($seconds): $ITEM_KEY,'$2' '$3' '$4' '$5' '$6' '$7' '$8' '$9'"
|
|
|
|
|
|
|
|
if [ -z "$ITEM_KEY" ]; then
|
|
|
|
key=$(echo $*|tr ' ' '_')
|
|
|
|
else
|
|
|
|
key="$(echo ${ITEM_KEY}|cut -d '[' -f 1)[$(shift; echo $*|tr ' ' ',')]"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! zaf_fromcache "$key"; then
|
2016-12-01 16:57:26 +01:00
|
|
|
tmpf=$(zaf_tmpfile cache)
|
|
|
|
$@ 2>"$tmpf" | zaf_tocache_stdin "$key" "$seconds"
|
|
|
|
[ -s $tmpf ] && zaf_wrn <$tmpf
|
2016-04-19 10:37:39 +02:00
|
|
|
fi
|
|
|
|
|