MySQL cache issues

11 views
Skip to first unread message

Joel Samuelsson

unread,
Apr 15, 2020, 5:17:59 AM4/15/20
to web2py-users
Got help earlier with keeping my database connections alive between requests:
https://groups.google.com/forum/#!topic/web2py/QraWtFvlqf8

I put my databases in a module like this:

class Databases():


 _td_db
= None


 
@staticmethod
 
def getTDDB():
     dbCreated
= False
     
if Databases._td_db is None:
         
Databases._td_db = DAL('mysql://' + TD_DB_MYSQL_USER + ':' + TD_DB_MYSQL_PASS + '@' + TD_DB_URL + ':' + TD_DB_PORT + '/TD')
         dbCreated
= True


 
return Databases._td_db, dbCreated

After doing this I get very weird issues:
- Writing a value sometimes fails with lock timeout
- Writing a value and then reading a value sometimes doesn't give the written value back but instead what was written before (cache issue?)

I find nothing in web2py documentation about inbuilt caching, any idea what may cause these issues?

Going back to always recreating the DAL object seems to fix the issues.
Reply all
Reply to author
Forward
0 new messages