项目作者: webcc

项目描述 :
Implementation of the session storage in Apache Cassandra as express middleware.
高级语言: JavaScript
项目地址: git://github.com/webcc/cassandra-store.git
创建时间: 2014-10-01T07:22:38Z
项目社区:https://github.com/webcc/cassandra-store

开源协议:Other

下载


cassandra-store

NPM Version
NPM Downloads
Node

Implementation of the session storage in Apache Cassandra
as an extension of the express-session middleware.
This version has been fully updated to ES6 and Node.js >= 10. For backwards
compatibility, use older versions of the package.

Installation

  1. $ npm install [-g] cassandra-store

Options

  1. {
  2. "table": "sessions",
  3. "client": null,
  4. "clientOptions": {
  5. "contactPoints": [ "localhost" ],
  6. "keyspace": "tests",
  7. "queryOptions": {
  8. "prepare": true
  9. }
  10. }
  11. }

If client is null or undefined, a new Cassandra client will be created.
Client options come from the Cassandra client driver (version 3.x).

Configuring the database

To create the table in the Cassandra database, you need the execute the
following CQL commands:

  1. USE tests;
  2. DROP TABLE IF EXISTS sessions;
  3. CREATE TABLE IF NOT EXISTS sessions (
  4. sid text,
  5. session text,
  6. expires timestamp,
  7. PRIMARY KEY(sid)
  8. );

Debugging

To activate debugging, set the environment variable NODE_DEBUG:

  1. $ export NODE_DEBUG=cassandra-store

Testing

See test/README.md

Usage

Usage within express:

  1. const session = require("express-session");
  2. const CassandraStore = require("cassandra-store");
  3. app.use(session({
  4. store: new CassandraStore(options),
  5. ...
  6. }));

TODO

  • Update to Cassandra driver Promises API