Permalink
Browse files

doc & rename daemon interval option

  • Loading branch information...
1 parent 4fbff4a commit 55bc003070e70f038d65fab3409ed1a7cfeef8ef @donpark donpark committed Jul 5, 2011
Showing with 24 additions and 26 deletions.
  1. +19 −21 README.md
  2. +2 −2 index.coffee
  3. +3 −3 index.js
View
@@ -10,25 +10,23 @@ Uses [mongeese](https://github/donpark/mongeese) module to isolate session datab
## Usage
-Replace code requiring `mongoose` module like this:
-
- var mongoose = require("mongoose");
- mongoose.connect(...);
-
-with:
-
- var mongoose = require("mongeese").create();
- mongoose.connect(...);
-
-Result of `create` method call should look and behave exactly like `mongoose` module
-except each result can have its own *default connection*.
-
-If you need to handle multiple databases at the same time, following should suffice:
-
- var logdb = require("mongeese").create();
- var keydb = require("mongeese").create();
-
- logdb.connect('mongodb://localhost/log');
- keydb.connect('mongodb://localhost/key');
-
+Create session store:
+
+ var SessionMongoose = require("session-mongoose");
+ var mongooseSessionStore = new SessionMongoose({
+ url: "mongodb://localhost/session",
+ interval: 120000 // expiration check worker run interval in millisec (default: 60000)
+ });
+
+Configure Express
+
+ var express = require("express");
+ ...
+ // configure session provider
+ app.use(express.session({
+ store: mongooseSessionStore,
+ ...
+ });
+ ...
+
That's it.
View
@@ -13,9 +13,9 @@ defaultCallback = (err) ->
class SessionStore extends require('connect').session.Store
constructor: (options) ->
- options?.expires ?= 60000
+ options?.interval ?= 60000
mongoose.connect options.url
- setInterval (-> Session.remove { expires: { '$lte': new Date() }}, defaultCallback), options.expires
+ setInterval (-> Session.remove { expires: { '$lte': new Date() }}, defaultCallback), options.interval
get: (sid, cb = defaultCallback) ->
Session.findOne { sid: sid }, (err, session) ->
View
Oops, something went wrong.

0 comments on commit 55bc003

Please sign in to comment.