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() + "_"
|
String key = new String(accountingType.name() + "_"
|
||||||
+ seriesRequest.toString());
|
+ seriesRequest.toString());
|
||||||
SeriesResponse seriesResponse = accountingCache.get(token, key);
|
SeriesResponse seriesResponse = accountingCache.get(aslSession.getScope(), key);
|
||||||
|
|
||||||
if (seriesResponse == null) {
|
if (seriesResponse == null) {
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
|
||||||
}
|
}
|
||||||
seriesResponse = accountingCaller.getSeries(accountingType,
|
seriesResponse = accountingCaller.getSeries(accountingType,
|
||||||
seriesRequest);
|
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 {
|
throws ServiceException {
|
||||||
try {
|
try {
|
||||||
String cacheName = ACCOUNTING_CACHE + token;
|
String cacheName = ACCOUNTING_CACHE + scope;
|
||||||
|
|
||||||
|
|
||||||
// create the cache
|
// 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 {
|
throws ServiceException {
|
||||||
Cache<String, SeriesResponse> cache = initCache(token);
|
Cache<String, SeriesResponse> cache = initCache(scope);
|
||||||
cache.put(key, value);
|
cache.put(key, value);
|
||||||
logger.debug("Cached: [" + key + ", " + value + "]");
|
logger.debug("Cached: ["+scope+", " + key + ", " + value + "]");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SeriesResponse get(String token, String key) throws ServiceException {
|
public SeriesResponse get(String scope, String key) throws ServiceException {
|
||||||
Cache<String, SeriesResponse> cache = initCache(token);
|
Cache<String, SeriesResponse> cache = initCache(scope);
|
||||||
SeriesResponse value = cache.get(key);
|
SeriesResponse value = cache.get(key);
|
||||||
logger.debug("Cached value: " + value);
|
logger.debug("Cached value: ["+scope+", " + value+"]");
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class TestAccountingManangerCache extends TestCase {
|
||||||
try {
|
try {
|
||||||
AccountingCache accountingCache=new AccountingCache();
|
AccountingCache accountingCache=new AccountingCache();
|
||||||
SeriesResponse s=new SeriesResponse();
|
SeriesResponse s=new SeriesResponse();
|
||||||
accountingCache.put("token","key", s);
|
accountingCache.put("scope","key", s);
|
||||||
accountingCache.finalize();
|
accountingCache.finalize();
|
||||||
assertTrue(true);
|
assertTrue(true);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue