> Hello, > > I am using the uWSGI cache feature to reduce the number of DB queries. The > flow looks like this (code is written in Python): > > request comes in: > > value = cache_get(key) > if value: > return value > else: > value = db_query(...) > cache_set(key, pickle.dumps(value), 60) > > It works well for few minutes. After that, it calls cache_set for some > keys more than once every 60 second (once a second or more frequently). I > would expect cache_set to not be called more than once every 60 seconds > because I pass expires=60 to cache_set. > > cache_get doesn't return anything even if cache_set succeeds (return value > is True). This is what worries me. > > Let me know if you need more details. > > uWSGI config: > > [uwsgi] > socket=/var/run/uwsgi.sock > master=true > enable-threads=true > listen=8192 > socket-timeout=60 > buffer-size=8192 > pidfile=/var/run/uwsgi.pid > module=app.start > pythonpath=blabla > processes=8 > threads=0 > daemonize=/var/log/uwsgi.log > disable-logging=false > logto=/var/log/uwsgi-access.log > logdate=true > no-orphans=true > vacuum=true > uid=user > gid=group > cache=10000 > cache-blocksize=4096 > cache-report-freed-items=true_______________________________________________ > uWSGI mailing list > [email protected] > http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi >
Just two things: - be sure to run a version >= 1.4.4 as older version had a corner-case bug in which collisioned keys could be swallowed (if you have lot of collisions you could have hit that) - remember that cache_set does not overwrite already-existent keys. Use cache_update if you want auto-overwrite. -- Roberto De Ioris http://unbit.it _______________________________________________ uWSGI mailing list [email protected] http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
