Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/main/java/io/vertx/httpproxy/impl/CacheImpl.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package io.vertx.httpproxy.impl;

import io.vertx.core.Future;
import io.vertx.core.internal.Closeable;
import io.vertx.httpproxy.cache.CacheOptions;
import io.vertx.httpproxy.spi.cache.Cache;
import io.vertx.httpproxy.spi.cache.Resource;

import java.time.Duration;
import java.util.*;

/**
* Simplistic implementation.
*/
public class CacheImpl implements Cache {
public class CacheImpl implements Cache, Closeable {

private final int maxSize;
private final Map<String, Resource> data;
Expand Down Expand Up @@ -43,4 +45,8 @@ public Future<Void> remove(String key) {
return Future.succeededFuture();
}

@Override
public Future<Void> shutdown(Duration timeout) {
return Future.succeededFuture();
}
}
14 changes: 8 additions & 6 deletions src/main/java/io/vertx/httpproxy/impl/ReverseProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.*;
import io.vertx.core.internal.CloseFuture;
import io.vertx.core.internal.CloseableResource;
import io.vertx.core.internal.VertxInternal;
import io.vertx.core.internal.http.HttpClientInternal;
import io.vertx.core.internal.logging.Logger;
Expand Down Expand Up @@ -51,12 +51,14 @@ public ReverseProxy(ProxyOptions options, HttpClient client) {

public Cache newCache(CacheOptions options, Vertx vertx) {
if (options.isShared()) {
CloseFuture closeFuture = new CloseFuture();
return ((VertxInternal) vertx).createSharedResource("__vertx.shared.proxyCache", options.getName(), closeFuture, (cf_) -> {
return new CacheImpl(options);
});
CloseableResource<CacheImpl> resource = ((VertxInternal) vertx).createSharedResource(
"__vertx.shared.proxyCache",
options.getName(),
() -> new CacheImpl(options));
return resource.get();
} else {
return new CacheImpl(options);
}
return new CacheImpl(options);
}

@Override
Expand Down