util.cache: Add head() and tail() methods (and tests)