'Store the given response in the cache.'

def store_response(self, spider, request, response):

    rpath = self._get_request_path(spider, request)
    if (not os.path.exists(rpath)):
        os.makedirs(rpath)
    metadata = {'url': request.url, 'method': request.method, 'status': response.status, 'response_url': response.url, 'timestamp': time()}
    with self._open(os.path.join(rpath, 'meta'), 'wb') as f:
        f.write(to_bytes(repr(metadata)))
    with self._open(os.path.join(rpath, 'pickled_meta'), 'wb') as f:
        pickle.dump(metadata, f, protocol=2)
    with self._open(os.path.join(rpath, 'response_headers'), 'wb') as f:
        f.write(headers_dict_to_raw(response.headers))
    with self._open(os.path.join(rpath, 'response_body'), 'wb') as f:
        f.write(response.body)
    with self._open(os.path.join(rpath, 'request_headers'), 'wb') as f:
        f.write(headers_dict_to_raw(request.headers))
    with self._open(os.path.join(rpath, 'request_body'), 'wb') as f:
        f.write(request.body)
