Simple session manager for spark. It retrieves all session attributes from Redis on every request, and save them back to Redis if session attributes were changed during request processing.
Add to your pom.xml:
<dependency>
<groupId>com.github.jeckep</groupId>
<artifactId>sparkjava-redis-session-manager</artifactId>
<version>0.3.0</version>
</dependency>
Add to your main app class:
public static void main(String[] args) {
final JedisPool pool = new JedisPool(new JedisPoolConfig(), "redis");
final PSF psf = new PSF(new RedisSimplePersister(new JedisThreadSafeConnector(pool)));
//before all before-filters
before("*", psf.getBeforeFilter());
//after all after-filters
after("*", psf.getAfterFilter());
}
If you don't want to use jedis as redis client, create you own class implementing RedisConnector instead of JedisConnector.
Think before use this in production. You can use it but on your own risk.