Yet another Database caching bug

@hrach: This one took me literally **ages** to isolate. Can you do something about it? :-)