-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Provide IMMEDIATE session updates on a method level of RedisOperationsSessionRepository #849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @beku8 - can you explain why you cannot call |
Hello, I tried to configure with
but it throws exception on the start up
we are on spring boot 1.5.3, thus spring session 1.3.1. I've tried with also couple of compinations of FindByIndexNameSessionRepository, RedisOperationsSessionRepository, SessionRepository. I thought they were somehow mutually exclusive. But as you mentioned, I noticed that I autowired SessionRepository, in other classes successfully. Any idea why this might be happening? |
There are basically two ways you can inject a Raw type approach: class RawConsumer {
@Autowired
private FindByIndexNameSessionRepository sessionRepository;
void consume() {
Session session = (Session) this.sessionRepository
.findByIndexNameAndIndexValue(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, "principal")
.values().iterator().next();
session.setAttribute("test", UUID.randomUUID().toString());
this.sessionRepository.save(session);
}
} Parameterized type approach: class ParameterizedConsumer<S extends Session> {
@Autowired
private FindByIndexNameSessionRepository<S> sessionRepository;
void consume() {
S session = this.sessionRepository
.findByIndexNameAndIndexValue(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, "principal")
.values().iterator().next();
session.setAttribute("test", UUID.randomUUID().toString());
this.sessionRepository.save(session);
}
} |
It works, and I feel stupid. Thanks :) |
Uh oh!
There was an error while loading. Please reload this page.
We wanted to update the session, as new role granted for the user. We can achieve this with the combination of
findByIndexNameAndIndexValue
methond and by settingRedisOperationsSessionRepository
onIMMEDIATE
flush mode. Since we can't callsave
, due to the package access ofRedisSession
. But I think its not necessary to convert toIMMEDIATE
just for this purpose.Would it be possible to provide a method like
setAttributeImmidiate(sessionId, name, value)
onRedisOperationsSessionRepository
?The text was updated successfully, but these errors were encountered: