ref: 1a51231062636c8de1324d2fa1ffa573c2e04ef7
parent: c0cc6b7980e6edce32822857a6a34dea390c4e90
author: Ori Bernstein <[email protected]>
date: Thu Jul 11 00:06:28 EDT 2024
list: add cache for list page on shithub, we have a lot of repos; this means we exec a lot of programs to generate the list page -- nearly 3000 of them. That gets a bit slow and puts a lot of load on the system.
--- a/list
+++ b/list
@@ -5,37 +5,46 @@
cd $1
shift
+cache=/usr/web/cache/shitlist.cache
+tcache=/usr/web/cache/shitlist.cache.tmp.$pid
+if(test -e $cache && ! test $cache -older 1m){
+ exec cat $cache
+ exit
+}
+
rfork ne
nl='
'
-prelude '' 'the fragrant git host'
-echo '<img src="/static/'$logo'" /><br/>'
-
-if(~ $#intro 0)
- echo '<h2>Repositories</h2><br/>'
-if not
- echo $intro
-
-udir=()
-for(repo in `$nl{ls -Q */}){
- ndir=`{basename -d $repo}
- if(! ~ $udir $ndir)
- echo '</dl>'
- if(! ~ $udir $ndir){
- echo '<h3><a href="/'$ndir'/usr.html" name="'$ndir'">'$ndir'</a></h3>'
- echo '<dl>'
- udir=$ndir
+{
+ prelude '' 'the fragrant git host'
+ echo '<img src="/static/'$logo'" /><br/>'
+
+ if(~ $#intro 0)
+ echo '<h2>Repositories</h2><br/>'
+ if not
+ echo $intro
+
+ udir=()
+ for(repo in `$nl{ls */}){
+ ndir=`{basename -d $repo}
+ if(! ~ $udir $ndir)
+ echo '</dl>'
+ if(! ~ $udir $ndir){
+ echo '<h3><a href="/'$ndir'/usr.html" name="'$ndir'">'$ndir'</a></h3>'
+ echo '<dl>'
+ udir=$ndir
+ }
+ if(test -e $repo/.git/webpublish){
+ echo '<dt><a href="/'$repo'/HEAD/info.html">'$repo'</a></dt>'
+ echo '<dd>'
+ if(test -f $repo/.git/desc)
+ htcat $repo/.git/desc
+ if not if(test -f $repo/.git/description)
+ htcat $repo/.git/description
+ if not
+ echo 'probably some code'
+ echo '</dd>'
+ }
}
- if(test -e $repo/.git/webpublish){
- echo '<dt><a href="/'$repo'/HEAD/info.html">'$repo'</a></dt>'
- echo '<dd>'
- if(test -f $repo/.git/desc)
- htcat $repo/.git/desc
- if not if(test -f $repo/.git/description)
- htcat $repo/.git/description
- if not
- echo 'probably some code'
- echo '</dd>'
- }
-}
+} | tee $tcache && mv $tcache $cache