Retrieving In-memory object by association returning empty

0
Hi there,  My goal is to check for inactivity of a client and send them to the homepage. I make use of a tracker tied to the current session, and whenever a user presses any key in an input field, it will reset the tracker’s datetime. But i would not like this tracker to be committed to the database. My problem is, if i do not commit a persistable object “tracker” into the database, i am unable to retrieve the newly created tracker to check for inactivity, no matter what. My knowledge of in-memory objects is that, as long as we don’t commit AND there’s still an association with a live object/page, the memory object would not be garbage collected. Please help! Details below: --------- I have a non-persistable database entity called “tracker” and it has an association to my session as such: --------- I create a tracker(if not already existing) and tag it to the session everytime somebody visits page A. If already exist, i’ll just return the existing tracker. This is my microflow(getTracker) that every page will call:   --------- All on key events, i would run this microflow(updateTracker) to update it to the latest time:    --------- This is the microflow that i’m constantly invoking on any page using the Widget called Microflow timer:   --------- So the big picture is, on every page, i’ll check if the tracker last active time has past a certain seconds (e.g. 15secs), if so, it’s considered inactive, and i’ll return to home page. Every key up events in an input field will trigger an update of the latest time active using updateTracker.  More information:  The microflow that contains the logic to go back home, resides on a separate module from the trackers. The getTracker and updateTracker resides together, in the same module as the “tracker” entity.   My view (resides together with my logic that routes back home) looks like this:   Feel free to ask more questions for any clarification, and thank you for taking the time to read this post!!   Best Regards, Raphael  EDIT1: I tried a working version using persistable entity, committed into the database and i could get the intended outcome of an inactivity redirect to home. The moment i switch the persistable entity to a non persistable entity, there it is not working anymore. I added breakpoints to check if my “getTracker” function is detecting any previously created tracker objects (tied to session), but the debugging showed me that, it’s not detecting any tracker object, and it’s constantly creating a new one which shouldn’t be the case. It should just create once, the first time, for a single session,  and constantly reuse that one until the session is destroyed. Below shows how i commit the tracker object and tag it to the session, when the “getTracker” creates one when it detects that no tracker is present:  
asked
1 answers
0

Hi Raphael

You should commit the value in the non-persistable entity. Otherwise it isn’t captured. 

Good luck!

Hans

answered