carmine icon indicating copy to clipboard operation
carmine copied to clipboard

[ring middleware] Reset session expiration on every read

Open svdo opened this issue 2 years ago • 2 comments

This change introduces a new option :extend-on-read? to the Ring middleware. By default it is false. When false, the session expiration will be set when it is created ~~(and not changed afterwards)~~ and when it is written (which normally doesn't happen when using the ring-session middleware). When true the session expiration is reset on every read, so that the session is always valid for the set number of seconds after it was last used.

Updated pull request for #259.

svdo avatar Feb 04 '22 20:02 svdo

@svdo Thanks Stefan! Will look at merging next time I'm doing some batched work on Carmine.

Just a heads-up that this part of your understanding isn't accurate:

When false, the session expiration will be set when it is created (and not changed afterwards)

When false, the session is also renewed on any session writes (changes).

I.e. the extend-on-read? options would be:

  • false (default): renew session only on session writes
  • true: renew session also on session reads

Hope that makes sense!

ptaoussanis avatar Feb 05 '22 09:02 ptaoussanis

Yes I understand, thanks for clarifying!!

svdo avatar Feb 05 '22 09:02 svdo

@svdo Will be merged in next release, thanks Stefan! Apologies for the long delay.

ptaoussanis avatar Dec 03 '22 09:12 ptaoussanis

No problem at all @ptaoussanis, I've been using my fork so that didn't cause any issues for me :)

svdo avatar Dec 03 '22 14:12 svdo