fix(db): query cache properly handles more callable types

The former query cache did not generate unique ids for callbacks. Notably all
array callbacks were considered the same.