Permalink
Browse files

Rewritten the module due to npm 1.x changes

  • Loading branch information...
balor committed Mar 6, 2012
1 parent afa0c79 commit a9273e443ffecfec22fea902e435d64e8011baeb
Showing with 492 additions and 376 deletions.
  1. +4 −0 History.md
  2. +2 −6 Makefile
  3. +41 −16 Readme.md
  4. +333 −0 doc.json
  5. +0 −263 index.html
  6. +109 −89 lib/connect-memcached.js
  7. +3 −2 package.json
View
@@ -1,3 +1,7 @@
+0.0.3 / 2012-03-06
+==================
+
+ * Rewritten the module due to npm 1.x changes (we now need to pass connect to the function connect-memcached exports in order to extend connect.session.Store:
0.0.2 / 2010-01-03
==================
View
@@ -1,6 +1,2 @@
-index.html: lib/connect-memcached.js
- dox \
- --title "connection-memcached" \
- --desc "Memcached session store for Connect" \
- --ribbon "https://github.com/balor/connection-memcached" \
- $< > $@
+doc.json: lib/connect-memcached.js
+ dox < $< > $@
View
@@ -11,22 +11,47 @@
## Example
- var connect = require('connect');
- var MemcachedStore = require('connect-memcached');
-
- connect.createServer(
- connect.cookieParser(),
- connect.session({
- store: new MemcachedStore({
- hosts: [
- '192.168.1.65:11213',
- '192.168.1.66:11213',
- '192.168.1.67:11213'
- ]
- }),
- secret: 'thisissosick'
- })
- );
+ /**
+ * Module dependencies.
+ */
+
+ var express = require('express');
+
+ // pass the express to the connect memcached module
+ // allowing it to inherit from express.session.Store
+ var MemcachedStore = require('connect-memcached')(express);
+
+ var app = express.createServer();
+
+ app.use(express.favicon());
+
+ // request logging
+ app.use(express.logger());
+
+ // required to parse the session cookie
+ app.use(express.cookieParser());
+
+ // Populates:
+ // - req.session
+ // - req.sessionStore
+ // - req.sessionID (or req.session.id)
+
+ app.use(express.session({
+ secret: 'CatOnTheKeyboard',
+ store: new MemcachedStore
+ }));
+
+ app.get('/', function(req, res){
+ if (req.session.views) {
+ ++req.session.views;
+ } else {
+ req.session.views = 1;
+ }
+ res.send('Viewed <strong>' + req.session.views + '</strong> times.');
+ });
+
+ app.listen(3000);
+ console.log('Express app started on port 3000');
## Options
Oops, something went wrong.

0 comments on commit a9273e4

Please sign in to comment.