backport from 1.9 (rev #9743)

properly set the prefixes len for cachedb