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:
parent
fb23cb9789
commit
a61b16d7fc
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue