Implemented cache writting