Cache size reporting.

This commit is contained in:
marcins78@gmail.com
2012-12-16 19:20:20 +00:00
parent 4d1b661d41
commit 1597e3c879
10 changed files with 48 additions and 2 deletions

View File

@@ -14,4 +14,11 @@ public class CacheManager {
for (Cached cache : _caches)
cache.clearCache();
}
public int getTotalCount() {
int total = 0;
for (Cached cache : _caches)
total+=cache.getItemCount();
return total;
}
}

View File

@@ -2,4 +2,5 @@ package com.gempukku.lotro.cache;
public interface Cached {
public void clearCache();
public int getItemCount();
}

View File

@@ -23,6 +23,11 @@ public class CachedCollectionDAO implements CollectionDAO, Cached {
_playerCollections.clear();
}
@Override
public int getItemCount() {
return _playerCollections.size();
}
@Override
public CardCollection getPlayerCollection(int playerId, String type) throws SQLException, IOException {
String key = constructCacheKey(playerId, type);

View File

@@ -16,12 +16,16 @@ public class CachedTransferDAO implements TransferDAO, Cached {
_delegate = delegate;
}
@Override
public void clearCache() {
_playersWithoutDelivery.clear();
}
@Override
public int getItemCount() {
return _playersWithoutDelivery.size();
}
public boolean hasUndeliveredPackages(String player) {
if (_playersWithoutDelivery.contains(player))
return false;

View File

@@ -25,6 +25,11 @@ public class CachedDeckDAO implements DeckDAO, Cached {
_decks.clear();
}
@Override
public int getItemCount() {
return _playerDeckNames.size()+_decks.size();
}
@Override
public LotroDeck buildDeckFromContents(String deckName, String contents) {
return _delegate.buildDeckFromContents(deckName, contents);

View File

@@ -20,6 +20,11 @@ public class CachedMerchantDAO implements MerchantDAO, Cached {
_blueprintIdLastTransaction.clear();
}
@Override
public int getItemCount() {
return _blueprintIdLastTransaction.size();
}
@Override
public void addTransaction(String blueprintId, float price, Date date, TransactionType transactionType) {
_delegate.addTransaction(blueprintId, price, date, transactionType);

View File

@@ -23,6 +23,11 @@ public class CachedPlayerDAO implements PlayerDAO, Cached {
_playerByName.clear();
}
@Override
public int getItemCount() {
return _playerById.size()+_playerByName.size();
}
@Override
public Player getPlayer(int id) {
Player player = (Player) _playerById.get(id);

View File

@@ -32,6 +32,11 @@ public class CachedLeagueMatchDAO implements LeagueMatchDAO, Cached {
}
}
@Override
public int getItemCount() {
return _cachedMatches.size();
}
@Override
public Collection<LeagueMatchResult> getLeagueMatches(String leagueId) {
_readWriteLock.readLock().lock();

View File

@@ -65,6 +65,11 @@ public class CachedLeagueParticipationDAO implements LeagueParticipationDAO, Cac
return leagueParticipants;
}
@Override
public int getItemCount() {
return _cachedParticipants.size();
}
@Override
public void clearCache() {
_readWriteLock.writeLock().lock();

View File

@@ -66,9 +66,13 @@ public class AdminResource extends AbstractResource {
_leagueService.clearCache();
_tournamentService.clearCache();
int before = _cacheManager.getTotalCount();
_cacheManager.clearCaches();
return "OK";
int after = _cacheManager.getTotalCount();
return "Before: "+before+"<br>OK<br>After: "+after;
}
@Path("/shutdown")