Skip to content

Commit

Permalink
FEATURE: add flush prefix message compact feature
Browse files Browse the repository at this point in the history
  • Loading branch information
JJungwoo committed May 25, 2021
1 parent 534184c commit fb21039
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions engines/default/items.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
#include "default_engine.h"
#include "item_clog.h"

#ifdef ENABLE_COMPACT_FLUSH_PREFIX
#define FLUSH_PREFIX_PRINT_INTERVAL 10 * 60 /* 600 sec */
#define FLUSH_PREFIX_PRINT_COUNT 10

static uint32_t flush_prefix_count;
static rel_time_t flush_prefix_interval;
#endif

static struct default_engine *engine=NULL;
static struct engine_config *config=NULL; // engine config
static struct items *itemsp=NULL;
Expand Down Expand Up @@ -460,9 +468,21 @@ static ENGINE_ERROR_CODE do_item_flush_expired(const char *prefix, const int npr
oldest_live = pt->oldest_live;

if (config->verbose) {
#ifdef ENABLE_COMPACT_FLUSH_PREFIX
if (flush_prefix_count < FLUSH_PREFIX_PRINT_COUNT) {
if (flush_prefix_count == 0) {
flush_prefix_interval = svcore->get_current_time();
}
flush_prefix_count++;
#endif
logger->log(EXTENSION_LOG_INFO, NULL, "flush prefix=%s when=%u client_ip=%s\n",
(prefix == NULL ? "<null>" : prefix),
when, svcore->get_client_ip(cookie));
#ifdef ENABLE_COMPACT_FLUSH_PREFIX
} else if (svcore->get_current_time() - flush_prefix_interval >= FLUSH_PREFIX_PRINT_INTERVAL) {
flush_prefix_count = 0;
}
#endif
}
} else { /* flush all */
if (when == 0) {
Expand Down

0 comments on commit fb21039

Please sign in to comment.