我在 AWS EC2 中部署了一个应用程序,有时(罕见),我无法连接并执行 redis 中的任何命令,我正在调查此问题的根本原因。
我正在使用 Spring boot + Redis (Elasticcache)。
我正在使用包装器来捕获任何异常以继续请求过程。
我的包装纸:
class RedisCacheWrapper implements Cache {
private final Cache delegate;
public RedisCacheWrapper(Cache redisCache) {
Assert.notNull(redisCache, "delegate cache must not be null");
this.delegate = redisCache;
}
@Override
public String getName() {
try {
return delegate.getName();
} catch (Exception e) {
return handleException(e);
}
}
@Override
public Object getNativeCache() {
try {
return delegate.getNativeCache();
} catch (Exception e) {
return handleException(e);
}
}
@Override
public ValueWrapper get(Object key) { …Run Code Online (Sandbox Code Playgroud)