Brian "Krow" Aker (krow) wrote,
Brian "Krow" Aker
krow

From the Solution Pool this evening...

The user has session data in memcached. It is set to expire after X period of time.

How do you update the database to know when the expiration happened?

Poll for the data.

When you create the session data add a "session_active" field to the account. If you create a session for the user set this to "on", otherwise default it to off.

Now insert the data into memcached and set an expire on it. Each time you fetch the data, touch it to last a bit longer.

How do you turn off the enum "session_active" in MySQL?

Write an Event in 5.1 and probe Memcached via UDF to find out if the data still exists. If it does not, update the field. Just select each row that showed an active session and check it.

I got asked this in IRC and had to think about the logic of this. I am not sure I would design a need into knowing if a session variable still existed or not, but it is good to know that it is possible. You could take this one step further and write a trigger on the user account, and update any session information based on a change to the user's account.

What might be nifty? If I came up with a generic way to group sets of commands into one packet. This would help with performance whenever you do this type of actions.
Subscribe
  • Post a new comment

    Error

    Comments allowed for friends only

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 13 comments