<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def write_to_cache(self, data, filename):
        ''' Writes data in JSON format to a file '''

        json_data = json.dumps(data, sort_keys=True, indent=2)
        cache = open(filename, 'w')
        cache.write(json_data)
        cache.close()