SQL cache fixed to work properly with update function