smrchy/redis-sessions — pull request #10 by chilipote (2014-11-19 08:12:45+00:00)
Title: [Redis-Session] - Add the expire command on create & set methods to allo...

Add the expire command on create & set methods to allow the the use of events, like expire emit providing by redis. If you just precise a ttl, the resource is well deleted but no event is triggered

Now i can
``` javascript

// Create the session
session.create({
app : rsapp,
id : idUser,
ip : ipUser,
ttl : 10,
d : {
cartToken: cartAdded.cartToken,
cartUid: cartAdded.uid
}}, function (err, sessionGen) {
cartAdded
._set('sessionToken', sessionGen.token).update();
});

rsKeyBeg = 'rs:'+yournamespace+':';

// Session is removed, an event is emitted from the redis server, and I can remove My cart
var eventNotifier = new RedisNotifier(redis, {
redis : { host : 1234, port : locahost},
expired : true,
del : true,
logLevel : 'INFO' //Defaults To INFO
});

eventNotifier.on('message', function(pattern, channelPattern, emittedKey) {
var channel = this.parseMessageChannel(channelPattern);
switch(channel.key) {
case 'expired':
cart.removeBySessionToken(emittedKey.replace(rsKeyBeg,''));
break;
default:
logger.debug("Unrecognized Channel Type:" + channel.type);
}
});

// My cart is removed

```