Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: caching mechanism and Re: PATCH Completion for _yum



2016/12/14 20:38, Oliver Kiddle <okiddle@xxxxxxxxxxx> wrote:

> "Jun T." wrote:
> 
>>>> if ( [[ ${+_dput_cfhosts} -eq 0 ]] || _cache_invalid dputhosts ) &&
>>>> ! _retrieve_cache dputhosts; then
>>>> - which makes no sense to me.
> 
>> I guess what is intended by the original code is to be sure to
>> regenerate
>> the data if the cache is invalid, even if the variable _dput_cfhosts
>> already exists in the current zsh.
> 
> That's not what that logic does though. Simplify the line to
>  if ( blah blah... ) && ! _retrieve_cache dputhosts
> 
> and you will see that it only regenerates the cache if _retrieve_cache
> fails. In practice the effect is that no cache is ever considered stale.

E = _dput_cfhosts exists
I = _cache_invalid
R = _retrieve_cache

orig = (!E or I) and !R
new  = !E and (I or !R)

!E I !R  orig  new
T  T  T   T     T
T  T  F   F     T   (1)
T  F  T   T     T
T  F  F   F     F
F  T  T   T     F   (2)
F  T  F   F     F
F  F  T   F     F
F  F  F   F     F

If _cache_invalid returns 0, then _retrieve_cache should return 1
(we can't retrieve from an invalid cache, unless another zsh has
refreshed the cache between the two calls).
So the case (1) above is impossible, and the only difference is the
case (2), i.e., _dput_cfhosts exists but cache is invalid (and
_retrieve_cache returns 1).


Jun



Messages sorted by: Reverse Date, Date, Thread, Author