All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.asynchttpclient.shaded.cookie.CookieEvictionTask Maven / Gradle / Ivy

There is a newer version: 2.12.3.1
Show newest version
package org.asynchttpclient.shaded.cookie;

import java.util.concurrent.TimeUnit;

import org.asynchttpclient.shaded.AsyncHttpClientConfig;

import org.asynchttpclient.shaded.io.netty.util.Timeout;
import org.asynchttpclient.shaded.io.netty.util.TimerTask;

/**
 * Evicts expired cookies from the {@linkplain CookieStore} periodically.
 * The default delay is 30 seconds. You may override the default using
 * {@linkplain AsyncHttpClientConfig#expiredCookieEvictionDelay()}.
 */
public class CookieEvictionTask implements TimerTask {

    private final long evictDelayInMs;
    private final CookieStore cookieStore;

    public CookieEvictionTask(long evictDelayInMs, CookieStore cookieStore) {
        this.evictDelayInMs = evictDelayInMs;
        this.cookieStore = cookieStore;
    }

    @Override
    public void run(Timeout timeout) throws Exception {
        cookieStore.evictExpired();
        timeout.timer().newTimeout(this, evictDelayInMs, TimeUnit.MILLISECONDS);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy