<commit_before>from app import cache
from app.models import Setting
from app.utils.helpers import get_or_create


class AppSettings(dict):
    def __setitem__(self, key, value):
        setting, created = get_or_create(Setting, name=key)
        setting.value = value
        setting.save()

        # Delete the Setting dictionary cache
        cache.delete_memoized(Setting.get_dict)

    def __setattr__(self, key, value):
        self.__setitem__(key, value)

    def __getitem__(self, key):
        return Setting.get_dict()[key]<commit_msg>Turn AppSettings into MutableMapping<commit_after>from collections import MutableMapping

from app import cache
from app.models import Setting
from app.utils.helpers import get_or_create


class AppSettings(MutableMapping):
    def __setitem__(self, key, value):
        setting, created = get_or_create(Setting, name=key)
        setting.value = value
        setting.save()

        # Delete the Setting dictionary cache
        cache.delete_memoized(Setting.get_dict)

    def __setattr__(self, key, value):
        self.__setitem__(key, value)

    def __getitem__(self, key):
        return Setting.get_dict()[key]

    def __iter__(self):
        return iter(Setting.get_dict())

    def __len__(self):
        return len(Setting.get_dict())

    def __delitem__(self, key):
        pass
{'fraction_non_alphanumeric': 0.08663181478715459, 'fraction_numerical': 0.0, 'mean_word_length': 3.267515923566879, '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': '880103', 'n_tokens_mistral': 387, 'n_tokens_neox': 376, 'n_words': 102}