This fixes #8325.  It now will cache the entries instead of querying the database again and again.