Pluggable caches in FinalFlatMap

Added an synchronous cache, pulled cache logic out thats used by the FFM. Allow ticks to trigger flushing.