- Make cache RemovalListener sync (no longer use executor).

- Fix #433
This commit is contained in:
DNx5 2016-02-05 23:26:46 +07:00
parent 05aec0f4fe
commit c9b884624d

View File

@ -34,9 +34,9 @@ public class CacheDataSource implements DataSource {
public CacheDataSource(DataSource src) { public CacheDataSource(DataSource src) {
this.source = src; this.source = src;
this.exec = Executors.newCachedThreadPool(); this.exec = Executors.newCachedThreadPool();
cachedAuths = CacheBuilder.newBuilder() this.cachedAuths = CacheBuilder.newBuilder()
.expireAfterWrite(5, TimeUnit.MINUTES) .expireAfterWrite(8, TimeUnit.MINUTES)
.removalListener(RemovalListeners.asynchronous(new RemovalListener<String, Optional<PlayerAuth>>() { .removalListener(new RemovalListener<String, Optional<PlayerAuth>>() {
@Override @Override
public void onRemoval(RemovalNotification<String, Optional<PlayerAuth>> removalNotification) { public void onRemoval(RemovalNotification<String, Optional<PlayerAuth>> removalNotification) {
String name = removalNotification.getKey(); String name = removalNotification.getKey();
@ -44,7 +44,7 @@ public class CacheDataSource implements DataSource {
cachedAuths.getUnchecked(name); cachedAuths.getUnchecked(name);
} }
} }
}, exec)) })
.build( .build(
new CacheLoader<String, Optional<PlayerAuth>>() { new CacheLoader<String, Optional<PlayerAuth>>() {
public Optional<PlayerAuth> load(String key) { public Optional<PlayerAuth> load(String key) {