Giter VIP home page Giter VIP logo

connect-memjs's People

Contributors

balor avatar gabrielmancini avatar jorrit avatar leohihimax avatar liamdon avatar odbol avatar rkilgore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

connect-memjs's Issues

no support for manually setting ttl in set method

hi,

i have been using this libray for a while now. but now i want to set my own ttl in set method i:e not using session maxage but there is no support for it in your libray. i have tried some code and seems to be working. i also have tried to update the same on the repo but not authorised. please have a look on the code

MemcachedStore.prototype.set = function(sid, sess, fn,maxAgettl) {
      sid = this.getKey(sid);

      try {
          var defaultCokie = { httpOnly: true, secure : false, maxAge : (4 * 60 * 60)};
          var cookie = sess.cookie && sess.cookie||defaultCokie;
          var maxAge = maxAgettl && maxAgettl||cookie.maxAge;
          var ttl = 'number' == typeof maxAge ? maxAge | 0 : oneDay
          var sess = JSON.stringify(sess);

          this.client.set(sid, sess, function() {
              fn && fn.apply(this, arguments);
          }, ttl);
      } catch (err) {
          fn && fn(err);
      } 
  };

Connect ECONNREFUSED

Hello,

I get the following error on the second request:

Error: connect ECONNREFUSED 127.0.0.1:11211
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16)

It is worth mentioning that the requests are different but they access the same user session.

Request 1:

router.get('/login',(req,res) => {
  var sess = req.session;
  sess.email = req.query.email;
  res.send('done');
});

Request 2:

router.get('/admin',(req,res) => {
  var sess = req.session;
  if(sess.email) {
      res.send(`Hello ${sess.email}`);
  } else {
      res.send('Please login first.');
  }
});

My config:

const session = require("express-session");
var MemcachedStore = require('connect-memjs')(session);

...

app.use(session({
    store: new MemcachedStore({
      hosts: ["127.0.0.1:11211"]
    }),
    secret: '....',
    resave: false,
    saveUninitialized: false,
    proxy: true,
    cookie: {
        maxAge: 1000 * 60 * 15
    }
}));

Thanks greetings.

set call is deprecated with memjs 0.10.0

with memjs 0.10.0 I get a deprecated notification:
MemJS SET: using deprecated call - arguments have changed

just change this:

  this.client.set(sid, sess,  function() {
      fn && fn.apply(this, arguments);
  }, ttl);

to:

  this.client.set(sid, sess, {expires:ttl}, function() {
      fn && fn.apply(this, arguments);
  });

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.