-
1. Re: How to modify values of elements in cache and changing lifespan
michal_szymanski Jul 3, 2010 3:12 PM (in response to michal_szymanski)sorry by mistake I clicked 'Post' it is missing part of question:
class Token {
private String tokenStr;
private Calendar validTill;
private int validPeriod;}
during loggin we set up validTill = when token expaire and what was initial validPeriod. When user make some activity we would like to change validTill adding validPeriod. Can I do it using this:
Token token = tokenCache.get(tokenStr);
Calendar tokenTime = Calendar.getInstance();
tokenTime.add(Calendar.SECOND, token.getValidPeriod());
token.setValidTill(tokenTime);in other words can I get element from token cache and change attributes of ths element or maybe I should get old one, create ne element with modified attributes , remove old one and put new one (or sould I use replace method?) ?
Second question. Is it possible to exend lifespan value after creation of element e.g after few minutes I would like exend expiration dat of token.
-
2. Re: How to modify values of elements in cache and changing lifespan
mircea.markus Jul 5, 2010 5:18 AM (in response to michal_szymanski)in other words can I get element from token cache and change attributes of ths element or maybe I should get old one, create ne element with modified attributes , remove old one and put new one (or sould I use replace method?) ?
If you're using replicated/distribuetd caches you need to put the object in the cache again, one way or the other (using replace or put). If you're using local caches you can operated on the object directly, witouth the need to re-put it into cache.
Second question. Is it possible to exend lifespan value after creation of element e.g after few minutes I would like exend expiration dat of token.
Just put it again, with new value for expiration?
-
3. Re: How to modify values of elements in cache and changing lifespan
michal_szymanski Jul 5, 2010 6:28 AM (in response to mircea.markus)now it is clear, thank you for help.