Session's DBStore can be made to have less db queries #185

Open
w0rm opened this Issue Oct 7, 2012 · 0 comments

Projects

None yet

1 participant

@w0rm

I find that session's DBStore can be made to have less "SELECT * FROM sessions" queries.

For example, it selects the session to decide if it exists in __setitem__ when performing if key in self: check.

But as I understand db.update already returns the number of updated records, and we could use it to check if db.insert is needed.

if  self.db.update(self.table, where="session_id=$key", data=pickled, vars=locals()) != 1:
    self.db.insert(self.table, False, session_id=key, data=pickled)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment