diff --git a/master.c b/master.c index 5851ced3..033571cf 100644 --- a/master.c +++ b/master.c @@ -118,9 +118,11 @@ void *cache_sweeper_loop(void *noarg) { sigfillset(&smask); pthread_sigmask(SIG_BLOCK, &smask, NULL); + if (!uwsgi.cache_expire_freq) uwsgi.cache_expire_freq = 3; + // remove expired cache items TODO use rb_tree timeouts for(;;) { - sleep(1); + sleep(uwsgi.cache_expire_freq); for (i = 0; i < (int) uwsgi.cache_max_items; i++) { uwsgi_wlock(uwsgi.cache_lock); if (uwsgi.cache_items[i].expires) { diff --git a/uwsgi.c b/uwsgi.c index f3a75013..6aa2c549 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -159,6 +159,7 @@ static struct uwsgi_option uwsgi_base_options[] = { {"cache-server", required_argument, 0, "enable the threaded cache server", uwsgi_opt_set_str, &uwsgi.cache_server, 0}, {"cache-server-threads", required_argument, 0, "set the number of threads for the cache server", uwsgi_opt_set_int, &uwsgi.cache_server_threads,0}, {"cache-no-expire", required_argument, 0, "disable auto sweep of expired items", uwsgi_opt_true, &uwsgi.cache_no_expire,0}, + {"cache-expire-freq", required_argument, 0, "set the frequency of cache sweeper scans (default 3 seconds)", uwsgi_opt_set_int, &uwsgi.cache_expire_freq,0}, {"queue", required_argument, 0, "enable shared queue", uwsgi_opt_set_int, &uwsgi.queue_size, 0}, {"queue-blocksize", required_argument, 0, "set queue blocksize", uwsgi_opt_set_int, &uwsgi.queue_store_sync, 0}, diff --git a/uwsgi.h b/uwsgi.h index ad13c631..29a2f6c1 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -1573,6 +1573,7 @@ struct uwsgi_server { size_t cache_filesize; int cache_store_sync; int cache_no_expire; + int cache_expire_freq; char *cache_server; int cache_server_threads;