BUG/MINOR: cache: do not display expired entries in "show cache"

It was mentioned in issue #12 that expired entries would appear with a
negative expire delay in "show cache". Instead of listing them, let's
just evict them.

This could be backported to all versions since this was reported on
1.8 already.
This commit is contained in:
Willy Tarreau 2022-04-13 11:21:39 +02:00
parent 15dbedd63d
commit f1de1b51ca

View File

@ -2599,12 +2599,21 @@ static int cli_io_handler_show_cache(struct appctx *appctx)
}
entry = container_of(node, struct cache_entry, eb);
chunk_printf(&trash, "%p hash:%u vary:0x", entry, read_u32(entry->hash));
for (i = 0; i < HTTP_CACHE_SEC_KEY_LEN; ++i)
chunk_appendf(&trash, "%02x", (unsigned char)entry->secondary_key[i]);
chunk_appendf(&trash, " size:%u (%u blocks), refcount:%u, expire:%d\n", block_ptr(entry)->len, block_ptr(entry)->block_count, block_ptr(entry)->refcount, entry->expire - (int)now.tv_sec);
next_key = node->key + 1;
if (entry->expire > now.tv_sec) {
chunk_printf(&trash, "%p hash:%u vary:0x", entry, read_u32(entry->hash));
for (i = 0; i < HTTP_CACHE_SEC_KEY_LEN; ++i)
chunk_appendf(&trash, "%02x", (unsigned char)entry->secondary_key[i]);
chunk_appendf(&trash, " size:%u (%u blocks), refcount:%u, expire:%d\n",
block_ptr(entry)->len, block_ptr(entry)->block_count,
block_ptr(entry)->refcount, entry->expire - (int)now.tv_sec);
} else {
/* time to remove that one */
delete_entry(entry);
entry->eb.key = 0;
}
appctx->ctx.cli.i0 = next_key;
shctx_unlock(shctx_ptr(cache));