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.
Merge pull request #6948 from mrclay/query_cache_callback

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