Giter VIP home page Giter VIP logo

light-session-4j's Introduction

light-session

light-4j framework build upon undertow server. Undertow manager session in single node module and doesn't support distributed session management.

Light-session aims to provide a common infrastructure for managing sessions in distributed environment.

Light-session provide different types of repository for distributed session management which include Hazelcast, JDBD and Redis.

Project module:

session-core --- core components and interfaces for the session management. It should be included any type of repository. And this module also provide in memory session manager for single node.

hazelcast-mananger --- use hazelcast as repository for session management. Session will be persisted in the hazelcast distributed cache repository.

jdbc-manager --- use RDBMS database as repository for session management. Session will be persisted in the database tables.

redis-manager --- use redis as repository for session management. Session will be persisted in the redis in-memory data structure store.

In memory session manager:

In memory session manager provided in the session-core module. System use the Caffeine as in memory cache to store the session:

https://github.com/ben-manes/caffeine

In server.yml file:

- com.networknt.session.SessionManager:
  - com.networknt.session.MapSessionManager

Hazelcast session manager

System use the Hazelcast as distributed cache repository to store the session:

In server.yml file:

- com.networknt.session.SessionManager:
  - com.networknt.session.hazelcast.HazelcastSessionManager

JDBC session manager

System provide two set of DDL script, one for Oracle, another for postgres. User need create the tables in the database before use the session management:

In server.yml file:

- com.networknt.session.SessionManager:
   - com.networknt.session.jdbc.JdbcSessionManager

Below is the sample for the script:

DROP table IF EXISTS light_session;
DROP table IF EXISTS light_session_attributes;


 CREATE TABLE light_session (
    session_id VARCHAR2(100) NOT NULL,
    creation_time bigint NOT NULL,
    last_access_time bigint NOT NULL,
    max_inactive_interval int,
    expiry_time bigint,
    principal_name VARCHAR(100),
    PRIMARY KEY(session_id)
  );




  CREATE TABLE light_session_attributes (
   session_id VARCHAR2(100) NOT NULL,
   attribute_name VARCHAR(200) NOT NULL,
   attribute_bytes BYTEA,
   PRIMARY KEY(session_id, attribute_name)
  );

Redis session manager

In server.yml file:

- com.networknt.session.SessionManager:
  - com.networknt.session.redis.RedisSessionManager

User need start redis server before build and test the application

Start Redis docker image:

docker run --name some-redis -p 6379:6379 -d redis redis-server --appendonly yes

Start redis bash:

docker exec -it some-redis bash

test connection:

/data# redis-cli ping

Result should be: PONG

light-session-4j's People

Contributors

gavinchenyan avatar stevehu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.