Removed ProxySessionCache:

This class is no longer required since responsibility of storage of
sessions now lies with the caller and it's functionality can be
achieved by not saving the returned optional.
This commit is contained in:
Rsl1122 2019-02-19 12:36:13 +02:00
parent a41a4683c6
commit 0d8c2f2824
4 changed files with 1 additions and 65 deletions

View File

@ -18,8 +18,6 @@ package com.djrapitops.plan.modules;
import com.djrapitops.plan.api.CommonAPI;
import com.djrapitops.plan.api.PlanAPI;
import com.djrapitops.plan.system.cache.ProxySessionCache;
import com.djrapitops.plan.system.cache.SessionCache;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.database.ProxyDBSystem;
import com.djrapitops.plan.system.importing.EmptyImportSystem;
@ -56,9 +54,6 @@ public interface ProxySuperClassBindingModule {
@Binds
ConnectionSystem bindProxyConnectionSystem(ProxyConnectionSystem proxyConnectionSystem);
@Binds
SessionCache bindProxySessionCache(ProxySessionCache proxySessionCache);
@Binds
ImportSystem bindImportSystem(EmptyImportSystem emptyImportSystem);

View File

@ -1,48 +0,0 @@
/*
* This file is part of Player Analytics (Plan).
*
* Plan is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License v3 as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Plan is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
*/
package com.djrapitops.plan.system.cache;
import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.system.database.DBSystem;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.Optional;
import java.util.UUID;
/**
* Proxy server specific SessionCache.
* <p>
* Used for overriding {@link SessionCache#endSession(UUID, long)}.
*
* @author Rsl1122
*/
@Singleton
public class ProxySessionCache extends SessionCache {
@Inject
public ProxySessionCache(DBSystem dbSystem) {
super();
}
@Override
public Optional<Session> endSession(UUID playerUUID, long time) {
removeSessionFromCache(playerUUID);
/* Proxy should not save sessions so session is not removed.. */
return Optional.empty();
}
}

View File

@ -38,6 +38,7 @@ public class SessionCache {
@Inject
public SessionCache() {
// Dagger requires empty inject constructor
}
public static Map<UUID, Session> getActiveSessions() {

View File

@ -53,16 +53,4 @@ public class SessionCacheTest {
assertTrue(cachedSession.isPresent());
assertEquals(session, cachedSession.get());
}
@Test
public void testBungeeReCaching() {
SessionCache cache = new ProxySessionCache(null);
cache.cacheSession(uuid, session);
Session expected = new Session(uuid, serverUUID, 0, "", "");
cache.cacheSession(uuid, expected);
Optional<Session> result = SessionCache.getCachedSession(uuid);
assertTrue(result.isPresent());
assertEquals(expected, result.get());
}
}