mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-24 05:18:58 +00:00
(api-service) Mq endpoint for flushing caches
This commit is contained in:
parent
00eb8b90dc
commit
08eed17e66
@ -11,6 +11,7 @@ import nu.marginalia.model.gson.GsonFactory;
|
||||
import nu.marginalia.search.client.SearchClient;
|
||||
import nu.marginalia.search.client.model.ApiSearchResults;
|
||||
import nu.marginalia.service.server.*;
|
||||
import nu.marginalia.service.server.mq.MqNotification;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.Marker;
|
||||
@ -58,6 +59,14 @@ public class ApiService extends Service {
|
||||
Spark.get("/public/api/:key/search/*", this::search, gson::toJson);
|
||||
}
|
||||
|
||||
@MqNotification(endpoint = "FLUSH_CACHES")
|
||||
public void flushCaches(String unusedArg) {
|
||||
logger.info("Flushing caches");
|
||||
|
||||
responseCache.flush();
|
||||
licenseService.flushCache();
|
||||
}
|
||||
|
||||
private Object search(Request request, Response response) {
|
||||
|
||||
String[] args = request.splat();
|
||||
|
@ -8,7 +8,6 @@ import nu.marginalia.api.model.ApiLicense;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import spark.Request;
|
||||
import spark.Spark;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@ -57,4 +56,8 @@ public class LicenseService {
|
||||
|
||||
throw new IllegalStateException("This is unreachable");
|
||||
}
|
||||
|
||||
public void flushCache() {
|
||||
licenseCache.clear();
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,10 @@ public class ResponseCache {
|
||||
return license.getKey() + ":" + queryString + ":" + queryParams;
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
cache.invalidateAll();
|
||||
}
|
||||
|
||||
public void cleanUp() {
|
||||
cache.cleanUp();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user