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 3af3a16
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions engines/default/items.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,19 @@ ENGINE_ERROR_CODE item_delete(const void *key, const uint32_t nkey, uint64_t cas
* Flushes expired items after a flush_all call
*/

#ifdef ENABLE_COMPACT_FLUSH_PREFIX
#define FLUSH_PREFIX_LOG_INTERVAL 1 * 60 /* 600 sec */
#define FLUSH_PREFIX_LOG_COUNT 2
#endif

static ENGINE_ERROR_CODE do_item_flush_expired(const char *prefix, const int nprefix,
rel_time_t when, const void *cookie)
{
#ifdef ENABLE_COMPACT_FLUSH_PREFIX
static uint16_t fplog_count = 0;
static uint16_t fplog_skip_count = 0;
static rel_time_t fplog_time = 0;
#endif
hash_item *iter, *next;
rel_time_t oldest_live;

Expand All @@ -460,9 +470,26 @@ 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 (fplog_count < FLUSH_PREFIX_LOG_COUNT) {
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));
fplog_count++;
} else {
fplog_skip_count++;
if (svcore->get_current_time() - fplog_time >= FLUSH_PREFIX_LOG_INTERVAL) {
logger->log(EXTENSION_LOG_INFO, NULL, "flush prefix skip count=%d\n", fplog_skip_count);
fplog_count = 0;
fplog_skip_count = 0;
fplog_time = svcore->get_current_time();
}
}
#else
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));
#endif
}
} else { /* flush all */
if (when == 0) {
Expand Down

0 comments on commit 3af3a16

Please sign in to comment.