Fixes some issues with the caching (see
http://www.sqlalchemy.org/trac/log/examples/dogpile_caching/caching_query.py)
refs #5078