remove duration parameter from CacheEngine::write

it isn't supposed to be a public property. Also move key manipulation
from Cache to CacheEngine instances
update mock to account for prefix usage
consolidate return early statements