Skip to content

jeckep/simple-sparkjava-redis-session-manager

Repository files navigation

Simple Redis Session Manager for sparkjava

License badge Maven Central

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.

Getting started

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());
}

Customisation

If you don't want to use jedis as redis client, create you own class implementing RedisConnector instead of JedisConnector.

Disclaimer

Think before use this in production. You can use it but on your own risk.

About

Simple redis session manager for spark (sparkjava)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages