GH-3672: Clean up Jdbc & ZK LockRegistry caches

Fixes https://github.com/spring-projects/spring-integration/issues/3672

* Clean up `JdbcLockRegistry`, `ZookeeperLockRegistry` cache automatically 
* setCapacity(int capacity) to cacheCapacity(int capacity)
* field rename `capacity`to `cacheCapacity`, add static
This commit is contained in:
Unseok Kim
2021-11-12 06:36:27 +09:00
committed by GitHub
parent 5452a6fbe6
commit db611028da
9 changed files with 447 additions and 42 deletions

View File

@@ -99,7 +99,7 @@ public final class RedisLockRegistry implements ExpirableLockRegistry, Disposabl
@Override
protected boolean removeEldestEntry(Entry<String, RedisLock> eldest) {
return size() > RedisLockRegistry.this.capacity;
return size() > RedisLockRegistry.this.cacheCapacity;
}
};
@@ -114,7 +114,7 @@ public final class RedisLockRegistry implements ExpirableLockRegistry, Disposabl
private final long expireAfter;
private int capacity = DEFAULT_CAPACITY;
private int cacheCapacity = DEFAULT_CAPACITY;
/**
* An {@link ExecutorService} to call {@link StringRedisTemplate#delete} in
@@ -168,11 +168,11 @@ public final class RedisLockRegistry implements ExpirableLockRegistry, Disposabl
/**
* Set the capacity of cached locks.
* @param capacity The capacity of cached lock, (default 100_000).
* @param cacheCapacity The capacity of cached lock, (default 100_000).
* @since 5.5.6
*/
public void setCapacity(int capacity) {
this.capacity = capacity;
public void setCacheCapacity(int cacheCapacity) {
this.cacheCapacity = cacheCapacity;
}
@Override