s4
changeset 406:1af18eeeffb3
Cache strategy revised to trace icon cache renewal
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Thu, 09 Feb 2017 09:38:51 +0900 |
parents | 6244bbb72400 |
children | 4d912c2d48df |
files | s4-blog.sh |
diffstat | 1 files changed, 20 insertions(+), 14 deletions(-) [+] |
line diff
1.1 --- a/s4-blog.sh Wed Feb 08 12:53:20 2017 +0900 1.2 +++ b/s4-blog.sh Thu Feb 09 09:38:51 2017 +0900 1.3 @@ -223,6 +223,22 @@ 1.4 cachedir="$td/$id"; test -d "$cachedir" || mkdir -p "$cachedir" 1.5 cachefile="$cachedir/$id.row" 1.6 stampfile="$cachedir/$id.stamp" 1.7 + 1.8 + # First, check the availability of user-icon. 1.9 + # If not existent, clear and reset row cache by rm $stampfile 1.10 + if [ -n "$icon" -a -s "$icon" ]; then 1.11 + icfn=`echo "$icon"|htmlescape` 1.12 + picon="<p class=\"proficon\"><a href=\"$hlink+$uid\"><img src=\"$icfn\"></a></p>" 1.13 + else 1.14 + picon="" 1.15 + if [ -n "$icon" ]; then 1.16 + echo "DELETE FROM user_s WHERE key='$iconcachekey' AND 1.17 + val=`sqlquotestr \"$icon\"`;" >> $iconcleaner 1.18 + fi 1.19 + rm -f "$stampfile" 1.20 + unset stampfile # No icon-image, do not construct row-cache 1.21 + fi 1.22 + 1.23 if test -s "$stampfile" && 1.24 test -s "$cachefile" && 1.25 { ts=`cat "$stampfile"`; test -n "$ts"; } && 1.26 @@ -235,18 +251,7 @@ 1.27 nt="<label style=\"font-size: 70%;\"><input type=\"checkbox\" 1.28 name=\"notifyto\" value=\"$uid\">返信通知送信</label>" 1.29 tdcls="__NEWCLS__repatt" 1.30 - if [ -n "$icon" -a -s "$icon" ]; then 1.31 - icfn=`echo "$icon"|htmlescape` 1.32 - picon="<p class=\"proficon\"><a href=\"$hlink+$uid\"><img src=\"$icfn\"></a></p>" 1.33 - else 1.34 - picon="" 1.35 - if [ -n "$icon" ]; then 1.36 - echo "DELETE FROM user_s WHERE key='$iconcachekey' AND 1.37 - val=`sqlquotestr \"$icon\"`;" >> $iconcleaner 1.38 - fi 1.39 - fi 1.40 - 1.41 - date "+%F %T" > $stampfile # Cache time stamp(is here good?) 1.42 + 1.43 cat<<EOF 1.44 <tr id="$id"> 1.45 <td class="$tdcls">$picon${edit:+<a href="$elink+$edit">編集</a> }#$aid 1.46 @@ -295,7 +300,7 @@ 1.47 -e "s|^|<a href=\"$catlink+$mrid\"><img src=\"data:image/$fmt,|" \ 1.48 -e "s|\$|\">$fnb</a>|" 1.49 # [ -d $td ] || mkdir -p "$td" 1.50 - rm -f "$stampfile" # img data stream is not suitable to cache 1.51 + unset stampfile # img data stream is not suitable to cache 1.52 echo $tm > $tsfile 1.53 fi 1.54 ;; 1.55 @@ -306,6 +311,7 @@ 1.56 done 1.57 echo "</td></tr>" 1.58 } > "$cachefile" ######## New ROW Creation Ends here ######## 1.59 + test -n "$stampfile" && date "+%F %T" > $stampfile 1.60 fi 1.61 # Printing a cached row 1.62 sed "/<td class=/s/__NEWCLS__/$new${new:+ }/" $cachefile 1.63 @@ -339,7 +345,7 @@ 1.64 <p id="bottom"> </p> 1.65 EOF 1.66 # Clean up orphaned icon cache 1.67 - [ -s $iconcleaner ] && sq $db < $iconcleaner 1.68 + [ -s $iconcleaner ] && query ".read '$iconcleaner'" 1.69 # Record access log 1.70 acclog blog $rowid 1.71 }