Navigation Menu

Skip to content

Commit

Permalink
cache: expire old caches when the max N caches is decreased
Browse files Browse the repository at this point in the history
Suggested by Gurunavi, Inc. Thanks!!!
  • Loading branch information
kou committed Apr 15, 2015
1 parent 219ed3e commit 5d2c354
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/ctx.c
Expand Up @@ -1734,10 +1734,18 @@ grn_cache_init(void)
grn_rc
grn_cache_set_max_n_entries(grn_ctx *ctx, grn_cache *cache, unsigned int n)
{
uint32_t current_max_n_entries;

if (!cache) {
return GRN_INVALID_ARGUMENT;
}

current_max_n_entries = cache->max_nentries;
cache->max_nentries = n;
if (n < current_max_n_entries) {
grn_cache_expire(cache, current_max_n_entries - n);
}

return GRN_SUCCESS;
}

Expand Down

0 comments on commit 5d2c354

Please sign in to comment.