Method and apparatus for copying data using cache