pull a nil check up one frame
extract methods out of the cache update method
extract a method for updating without a record object
remove duplicate code
extract cache counter logic to one method