GithubHelp home page GithubHelp logo

Comments (4)

beckend avatar beckend commented on May 31, 2024 1

I have been sitting here debugging my code, I am doing redirects and various XHR requests and my handlers and then gets a new session ID which was the cause not having an old state, sorry for the noise.

from tower-sessions.

maxcountryman avatar maxcountryman commented on May 31, 2024

Can you provide an example?

Currently the session itself will be filtered by the active flag. (However this design will likely change in the future such that stores must enforce this semantic on their own.) This means a session that's expired will not be available in a route once it's been loaded.

from tower-sessions.

beckend avatar beckend commented on May 31, 2024
async fn handler1(session: Session) -> impl IntoResponse {
    let counter: Counter = session
        .get(COUNTER_KEY)
        .expect("Could not deserialize.")
        .unwrap_or_default();

    session
        .insert(COUNTER_KEY, counter.0 + 1)
        .expect("Could not serialize.");

    format!("Current count: {}", counter.0)
}

// later in app hitting:
async fn handler2(session: Session) -> impl IntoResponse {
    let counter: Counter = session
        .get(COUNTER_KEY)
        .expect("Could not deserialize.")
        .unwrap_or_default();

   // the insert did not update the value, you get the old value
    format!("Current count: {}", counter.0)
}

This works fine for postgresql, moka does not.

from tower-sessions.

maxcountryman avatar maxcountryman commented on May 31, 2024

So far I'm not able to replicate a discrepancy between CachingSessionStore and another store. Note the codepath is the same: both save methods are invoked in sequence in the save future of the caching store.

Can you provide a complete example that clearly demonstrates the issue you're seeing? I would like to be able to replicate it locally ideally.

from tower-sessions.

Related Issues (20)

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.