Skip to content

Commit

Permalink
feat: Added methods to manually remove connections from the cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdutz committed Sep 25, 2023
1 parent 8a3be82 commit c8e7fc9
Showing 1 changed file with 19 additions and 0 deletions.
Expand Up @@ -58,6 +58,25 @@ public CachedPlcConnectionManager(PlcConnectionManager connectionManager, Durati
this.connectionContainers = new HashMap<>();
}

/**
* @return set of connection-urls the CachedPlcConnectionManager is currently managing.
*/
public Set<String> getCachedConnections() {
synchronized (connectionContainers) {
return connectionContainers.keySet();
}
}

/**
* Removes a given connection from the cache (Should only be used in order to remove somehow broken connections).
* @param url url of the connection that should be removed.
*/
public void removeCachedConnection(String url) {
synchronized (connectionContainers) {
connectionContainers.remove(url);
}
}

public PlcConnection getConnection(String url) throws PlcConnectionException {
ConnectionContainer connectionContainer;
synchronized (connectionContainers) {
Expand Down

0 comments on commit c8e7fc9

Please sign in to comment.