MEDIUM: cache: Add a secondary entry counter and insertion limitation
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Thu, 10 Dec 2020 16:58:41 +0000 (17:58 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Tue, 15 Dec 2020 15:35:09 +0000 (16:35 +0100)
commit65904e4f07e6ac416178549dbc7385929d0b0ebc
tree7470b3c7ba01f35481648f7e68896c61b704818b
parentec609098718b9c1cd803ca57442b2b98c9ba4a16
MEDIUM: cache: Add a secondary entry counter and insertion limitation

Add an arbitrary maximum number of secondary entries per primary hash
(10 for now) to the cache. This prevents the cache from being filled
with duplicates of the same resource.
This works thanks to an entry counter that is kept in one of the
duplicates of the list (the last one).
When an entry is added to the list, the ebtree's implementation ensures
that it will be added to the end of the existing list so the only thing
to do to keep the counter updated is to get the previous counter from
the second to last entry.
Likewise, when an entry is explicitely deleted, we update the counter
from the list's last item.
src/cache.c