tangled
alpha
login
or
join now
zio.sh
/
atfile
37
fork
atom
๐ฆโ๐ฆ Store and retrieve files on the Atmosphere
37
fork
atom
overview
issues
3
pulls
pipelines
add debug messages for cache
ducky.ws
4 months ago
226e3498
5d9c9cda
1/1
build.yaml
success
4mo ago
+18
-1
1 changed file
expand all
collapse all
unified
split
src
shared
cache.sh
+18
-1
src/shared/cache.sh
···
1
1
#!/usr/bin/env bash
2
2
3
3
+
function atfile.cache.debug() {
4
4
+
key="$1"
5
5
+
action="$2"
6
6
+
output="$3"
7
7
+
8
8
+
[[ -z "$output" ]] && output="(Empty)"
9
9
+
10
10
+
atfile.say.debug "$action '$key' cache...\nโณ $output"
11
11
+
}
12
12
+
3
13
function atfile.cache.del() {
4
14
key="$(atfile.util.get_cache_path "$1")"
15
15
+
16
16
+
atfile.cache.debug "$1" "Deleting"
5
17
[[ -f "$key" ]] && rm "$key"
6
18
}
7
19
8
20
function atfile.cache.get() {
9
21
key="$(atfile.util.get_cache_path "$1")"
10
10
-
[[ -f "$key" ]] && cat "$key"
22
22
+
unset value
23
23
+
24
24
+
atfile.cache.debug "$1" "Getting" "$value"
25
25
+
[[ -f "$key" ]] && value="$(cat $key)"
26
26
+
echo "$value"
11
27
}
12
28
13
29
function atfile.cache.set() {
14
30
key="$(atfile.util.get_cache_path "$1")"
15
31
value="$2"
16
32
33
33
+
atfile.cache.debug "$1" "Setting" "$value"
17
34
# shellcheck disable=SC2154
18
35
mkdir -p "$_path_cache"
19
36
echo "$value" > "$key"