<commit_before>from __future__ import with_statement
import os
import pickle
from contextlib import closing
try:
    from redis import Redis
except ImportError:
    Redis = None


class Cache(object):
    def __init__(self):
        self._cache = {}

    def get(self, k):
        return self._cache.get(k)

    def set(self, k, v):
        self._cache[k] = v


class PickleCache(Cache):
    def __init__(self, filename='cache.db'):
        self.filename = filename
        self._cache = self.load()
    
    def load(self):
        if os.path.exists(self.filename):
            with closing(open(self.filename, 'rb')) as fh:
                return pickle.load(fh)
        return {}

    def save(self):
        with closing(open(self.filename, 'wb')) as fh:<commit_msg>Remove a redundant use of contextlib.closing() decorator<commit_after>from __future__ import with_statement
import os
import pickle
try:
    from redis import Redis
except ImportError:
    Redis = None


class Cache(object):
    def __init__(self):
        self._cache = {}

    def get(self, k):
        return self._cache.get(k)

    def set(self, k, v):
        self._cache[k] = v


class PickleCache(Cache):
    def __init__(self, filename='cache.db'):
        self.filename = filename
        self._cache = self.load()
    
    def load(self):
        if os.path.exists(self.filename):
            with open(self.filename, 'rb') as fh:
                return pickle.load(fh)
        return {}

    def save(self):
        with open(self.filename, 'wb') as fh:
{'fraction_non_alphanumeric': 0.11147327249022164, 'fraction_numerical': 0.0, 'mean_word_length': 2.4417040358744395, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6093092', 'n_tokens_mistral': 485, 'n_tokens_neox': 467, 'n_words': 131}