Permalink
Browse files

no longer need to JSON.parse/stringify as supermarket does it itself

  • Loading branch information...
1 parent 0fafbac commit 1256b335e5bf3b93cdb0587ff244701d45243d3e @pkrumins committed Sep 15, 2010
Showing with 7 additions and 10 deletions.
  1. +5 −8 lib/cart.js
  2. +2 −2 package.json
View
@@ -12,12 +12,11 @@ function Cart(options) {
options.maxAge = options.maxAge || 3600000; // Expunge after an hour
var dbFile = options.dbFile || __dirname + "/sessions.db";
ConnectStore.call(this, options);
- Store(dbFile, function (err, db) {
+ Store({ filename : dbFile, json : true }, function (err, db) {
if (err) throw err;
self.db = db;
db.filter(
function (key, item) {
- item = JSON.parse(item);
return item.lastAccess > Date.now() - options.maxAge;
},
function (key, item) {
@@ -33,7 +32,7 @@ Cart.prototype.get = function (hash, fn) {
this.db.get(hash, function (err, val) {
if (err) throw err;
if (val) {
- fn(null, JSON.parse(val));
+ fn(null, val);
}
else {
fn();
@@ -42,7 +41,7 @@ Cart.prototype.get = function (hash, fn) {
};
Cart.prototype.set = function (hash, sess, fn) {
- this.db.set(hash, JSON.stringify(sess), function (err) {
+ this.db.set(hash, sess, function (err) {
if (err) throw err;
if (fn) fn();
});
@@ -56,10 +55,8 @@ Cart.prototype.destroy = function (hash, fn) {
};
Cart.prototype.length = function (fn) {
- process.nextTick(function () {
- this.db.length(function (err, len) {
- fn(null, len);
- });
+ this.db.length(function (err, len) {
+ fn(null, len);
});
};
View
@@ -1,6 +1,6 @@
{
"name" : "cart",
- "version" : "1.0.0",
+ "version" : "1.0.1",
"description" : "Connect session store using supermarket",
"modules" : {
"index" : "./lib/cart.js"
@@ -26,7 +26,7 @@
"node": ">=0.2.0"
},
"dependencies" : {
- "supermarket" : ">=1.0.5"
+ "supermarket" : ">=1.0.6"
}
}

0 comments on commit 1256b33

Please sign in to comment.