0

I have a Map containing users that have been authenticated with my system. the key is the token that's being generated, the value is the actual user instance. Now I'd like to remove a user after a certain amount of inactivity. I am more than sure, there's a mechanism available for this (something like Googles LoadingCache but specially for this situation (login/tokenstorage) Could you suggest one?

Christian
  • 6,961
  • 10
  • 54
  • 82

1 Answers1

1

You could use ehcache for this purposes.

It's easy to use and it allows you to define various invalidation criteria for the tokens, such as timeToIdleSeconds and timeToLiveSeconds.

Another advantage of using ehcache for tokens is out of the box clustering support. Tokens can be synchronized (or deprovisioned in case of logout) between cluster nodes.

There a few ehcache hello world examples in SO. Your can extend them with dynamic configuration to archive what you need.

Community
  • 1
  • 1
Alexander Pranko
  • 1,859
  • 17
  • 20