use memory cache for length of database