Updated cache behavior

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@134039 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-11-10 13:26:09 +00:00
parent fb23cb9789
commit a61b16d7fc
3 changed files with 11 additions and 11 deletions

View File

@ -147,7 +147,7 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
String key = new String(accountingType.name() + "_"
+ seriesRequest.toString());
SeriesResponse seriesResponse = accountingCache.get(token, key);
SeriesResponse seriesResponse = accountingCache.get(aslSession.getScope(), key);
if (seriesResponse == null) {
@ -159,7 +159,7 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
}
seriesResponse = accountingCaller.getSeries(accountingType,
seriesRequest);
accountingCache.put(token, key, seriesResponse);
accountingCache.put(aslSession.getScope(), key, seriesResponse);
}

View File

@ -45,10 +45,10 @@ public class AccountingCache implements Serializable {
}
}
private Cache<String, SeriesResponse> initCache(String token)
private Cache<String, SeriesResponse> initCache(String scope)
throws ServiceException {
try {
String cacheName = ACCOUNTING_CACHE + token;
String cacheName = ACCOUNTING_CACHE + scope;
// create the cache
@ -94,18 +94,18 @@ public class AccountingCache implements Serializable {
}
public void put(String token, String key, SeriesResponse value)
public void put(String scope, String key, SeriesResponse value)
throws ServiceException {
Cache<String, SeriesResponse> cache = initCache(token);
Cache<String, SeriesResponse> cache = initCache(scope);
cache.put(key, value);
logger.debug("Cached: [" + key + ", " + value + "]");
logger.debug("Cached: ["+scope+", " + key + ", " + value + "]");
}
public SeriesResponse get(String token, String key) throws ServiceException {
Cache<String, SeriesResponse> cache = initCache(token);
public SeriesResponse get(String scope, String key) throws ServiceException {
Cache<String, SeriesResponse> cache = initCache(scope);
SeriesResponse value = cache.get(key);
logger.debug("Cached value: " + value);
logger.debug("Cached value: ["+scope+", " + value+"]");
return value;
}

View File

@ -30,7 +30,7 @@ public class TestAccountingManangerCache extends TestCase {
try {
AccountingCache accountingCache=new AccountingCache();
SeriesResponse s=new SeriesResponse();
accountingCache.put("token","key", s);
accountingCache.put("scope","key", s);
accountingCache.finalize();
assertTrue(true);