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

io.mstream.trader.datafeed.handlers.admin.cache.ClearCacheHandler Maven / Gradle / Ivy

The newest version!
package io.mstream.trader.datafeed.handlers.admin.cache;


import ratpack.handling.Context;
import ratpack.handling.Handler;

import javax.cache.Cache;
import javax.inject.Inject;
import java.util.HashMap;
import java.util.Map;

import static java.util.Collections.unmodifiableMap;


class ClearCacheHandler
        implements Handler {
    
    private final Map caches;
    
    @Inject
    ClearCacheHandler(Map caches) {
        
        this.caches = unmodifiableMap(new HashMap<>(caches));
    }
    
    @Override
    public void handle(Context context)
            throws Exception {
        
        caches
                .values()
                .forEach(Cache::clear);
        
        context
                .getResponse()
                .status(204)
                .send();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy