Fix connection to use specified db number

Cache always uses db0 instead of specified db number. This commit should fix that.