carmine icon indicating copy to clipboard operation
carmine copied to clipboard

Ring middleware: expiration is not reset when session key is read

Open svdo opened this issue 2 years ago • 4 comments

Steps to reproduce:

  1. Create a project using ring and this carmine ring session middleware
  2. Configure the carmine store to have a session expiration of 10 seconds
  3. Login and verify in Redis monitor that the session is created
  4. Wait five seconds and refresh the browser; in Redis monitor you can see that the keys is read
  5. Wait six seconds and refresh the browser

Expected behavior: session is still active because only six seconds have passed after the last request

Actual behavior: session has expired because more than 10 seconds have passed after the session was created.

See PR #254.

svdo avatar Feb 04 '22 11:02 svdo

@svdo Hi Stefan, thanks for this!

The current behaviour is intentional though, and documented here.

There's cases where one might want to refresh session on write only, and cases where one might want to refresh on reads too.

Your proposed change would break the documented behaviour, so isn't an option. But would be open to see a PR that extends carmine-store to add a new :extend-on-read? option (default false).

Hope that makes sense!

Cheers :-)

ptaoussanis avatar Feb 04 '22 11:02 ptaoussanis

Thanks for your quick response @ptaoussanis! Thanks for pointing out the backward compatibility issue, I agree that this should be behind an option. I'll modify the PR accordingly.

Do you mind about the inclusion of deps.edn that I did?

svdo avatar Feb 04 '22 12:02 svdo

Do you mind about the inclusion of deps.edn that I did?

Would prefer that be a separate PR, thanks!

ptaoussanis avatar Feb 04 '22 12:02 ptaoussanis

@ptaoussanis I have created as new pull request. Please let me know if this needs any more work!

svdo avatar Feb 04 '22 20:02 svdo

PR merged, closing. Thanks again!

ptaoussanis avatar Dec 03 '22 10:12 ptaoussanis