From: Pietro Cerutti Date: Tue, 20 Aug 2019 11:24:16 +0000 (+0000) Subject: Clarify hcache invalidation mechanism X-Git-Tag: 2019-10-25~94 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7f0d11c5a56cec27d117593588ccb723d0d4f59c;p=neomutt Clarify hcache invalidation mechanism --- diff --git a/hcache/README.md b/hcache/README.md index 668592edd..e007e773c 100644 --- a/hcache/README.md +++ b/hcache/README.md @@ -11,3 +11,16 @@ There are six different databases to choose from: Each backend implements the interface which is defined in `hcache.h` +# Operation + +The header cache works by caching a number of fields from a number of structs. +These are hardcoded in the `serial_*` functions in implemented in +`hcache/serialize.c`. The header cache has a CRC checksum that gets invalidated +whenever the definition of any of the structs defined in the `STRUCTURES` +variable in `hcache/hcachever.sh` changes. So, changes to any structure +definition, or addition / removal of a structure to / from the `STRUCTURES` +variable trigger an invalidation of any stored header cache. However, the CRC +is **not** invalidated whenever a new field from a structure is added or +removed to the set of the serialized fields. If you add or remove any fields in +any of the functions in `hcache/serialize.c`, please bump the `BASEVERSION` +variable in `hcache/hcachever.sh`. diff --git a/hcache/hcachever.sh b/hcache/hcachever.sh index 7b6bfe6f9..a9c849b3b 100755 --- a/hcache/hcachever.sh +++ b/hcache/hcachever.sh @@ -1,6 +1,7 @@ #!/bin/sh BASEVERSION=2 +STRUCTURES="Address Body Buffer Email Envelope ListNode Parameter" cleanstruct () { echo "$1" | sed -e 's/.* //' @@ -45,12 +46,12 @@ getstruct () { esac done - case $STRUCT in - Address|Body|Buffer|Email|Envelope|ListNode|Parameter) + for s in ${STRUCTURES}; do + if [ ${STRUCT} = $s ]; then BODY=`cleanbody "$BODY"` echo "$STRUCT: $BODY" - ;; - esac + fi + done return }