Skip to content

Commit fefb73c

Browse files
committed
feat(appserver): implement thread mapping store
1 parent 5913bd0 commit fefb73c

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/main/java/io/github/easy4j/codex/appserver/ThreadMappingCache.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* @since 3.0.0
3434
* @see CodexAppServerClient
3535
*/
36-
public class ThreadMappingCache {
36+
public class ThreadMappingCache implements ThreadMappingStore {
3737

3838
private final Map<String, String> mappings;
3939

@@ -59,6 +59,7 @@ protected boolean removeEldestEntry(Map.Entry<String, String> eldest) {
5959
* @param key session key; must not be {@code null}.
6060
* @return the mapped thread id, or {@code null} when absent.
6161
*/
62+
@Override
6263
public synchronized String get(String key) {
6364
Objects.requireNonNull(key, "key");
6465
return mappings.get(key);
@@ -70,12 +71,19 @@ public synchronized String get(String key) {
7071
* @param key session key; must not be {@code null}.
7172
* @param threadId Codex thread id; must not be {@code null}.
7273
*/
74+
@Override
7375
public synchronized void put(String key, String threadId) {
7476
Objects.requireNonNull(key, "key");
7577
Objects.requireNonNull(threadId, "threadId");
7678
mappings.put(key, threadId);
7779
}
7880

81+
@Override
82+
public synchronized void remove(String key) {
83+
Objects.requireNonNull(key, "key");
84+
mappings.remove(key);
85+
}
86+
7987
/**
8088
* Returns the current number of cached mappings.
8189
*

0 commit comments

Comments
 (0)