npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@matteo.bruni/hazelcast-store

v1.0.6

Published

Hazelcast implementation of expressjs session store

Downloads

10

Readme

hazelcast-store in an implementation of express session store based on the hazelcast-nodejs-client.

This module allow to replicate an HTTP session among all nodejs processes, even on different machines This module allow to propagate the HTTP session on more than one shared map, with different serialization beans

Create an instance of HazelcastStore

In order to initialize the module you need to

  • initialize the express-session module
  • initialize an instance of the HazelcastStore
  • connect an hazelcast-client to an active hazelcast cluster
  • when the hazelcast client is ready you can pass it to the HazelcastStore via the method setClient
  • finally you can initialize the session middleware of expressjs
const session = require('express-session');
const HazelcastStore = require('hazelcast-store')(session);
const hazelcastStore = new HazelcastStore();

const HazelcastClient = require('hazelcast-client').Client;
const HazelcastConfig = require('hazelcast-client').Config;
const clientConfig = new HazelcastConfig.ClientConfig();
clientConfig.networkConfig.addresses = ['127.0.0.1:5701'];

HazelcastClient.newHazelcastClient(clientConfig)
    .then((hzInstance) => {
        hazelcastStore.setClient(hzInstance);
        app.use(session({ store: hazelcastStore, secret: 'mySecret', name: 'myCookieName' }));
    });

This module has a set of options available

const defaultOptions = {
    disableTTL: false,
    ttl: 86400000,
    maps: [
        { mapName: "Sessions" }
    ]
};
  • disableTTL: by default is false and the TTL specified in the ttl configuration or in maxAge cookie parameter will beused.
  • ttl: by default 86400000 (24h) millis. It the time to live of the sessions, if cookie maxAge is not specified.
  • maps: is an array of elements that represent the maps that should be used as storage for the HTTP session. At least one map should be specified. By default will be created a map called "Sessions".

This module implements all required and optional method suggested in express session store implementation:

  • store.all
  • store.destroy
  • store.clear
  • store.length
  • store.get
  • store.set
  • store.touch

This module has been tested with:

  • express-store: 1.15.0 and above
  • hazelcast-client: 0.10.0. It works also with older version of hazelcast because this module handle correctly the change of method hzClient.getMap(mapName) from synchronous method to promise.

Advanced Usage

This module support the sinchronization of HTTP session among a list of hazelcast maps with different bean serialization. If the configuration contains something like:

let options = {
    maps: [
        { 
            mapName: "Sessions" 
        },
        { 
            mapName: "MyCustomSessions",
            bean: MyConstructorBean 
        }
    ]
};

this library will set the HTTP session value in the first map Sessions and in the replica map MyCustomSession with a value obtained via the custom constructor:

MyConstructorBean(session)

instead of the entire content of the session

session

In this way you can customize the content of the HTTP session map.