<commit_before>#include "appcache.h"
#include "util.h"
#include "main.h"

#include <boost/algorithm/string.hpp>

namespace
{
    AppCache mvApplicationCache;
}

void WriteCache(
        const std::string& section,
        const std::string& key,
        const std::string& value,
        int64_t locktime)
{
    if (section.empty() || key.empty())
        return;

    mvApplicationCache[section][key] = AppCacheEntry{ value, locktime };
}

AppCacheEntry ReadCache(
        const std::string& section,
        const std::string& key)
{
    if (section.empty() || key.empty())
        return AppCacheEntry{};

    const auto& cache = ReadCacheSection(section);
    auto entry = cache.find(key);
    return entry != cache.end()
                   ? entry->second
                   : AppCacheEntry{std::string(), 0};
}

AppCacheSection ReadCacheSection(const std::string& section)
{
    const auto& cache = mvApplicationCache.find(section);
    return cache != mvApplicationCache.end()
        ? cache->second
        : AppCacheSection();
}

void ClearCache(const std::string& section)
{
    auto cache = mvApplicationCache.find(section);
    if(cache == mvApplicationCache.end())
        return;

    for(auto& item : cache->second)
    {
        AppCacheEntry& entry = item.second;
        entry.value.clear();
        entry.timestamp = 1;
    }
}

void DeleteCache(const std::string& section, const std::string& key)
{
    auto cache = mvApplicationCache.find(section);
    if(cache == mvApplicationCache.end())
       return;

    cache->second.erase(key); 
}<commit_msg>ClearCache will now erase the entire section from the cache.<commit_after>#include "appcache.h"
#include "util.h"
#include "main.h"

#include <boost/algorithm/string.hpp>

namespace
{
    AppCache mvApplicationCache;
}

void WriteCache(
        const std::string& section,
        const std::string& key,
        const std::string& value,
        int64_t locktime)
{
    if (section.empty() || key.empty())
        return;

    mvApplicationCache[section][key] = AppCacheEntry{ value, locktime };
}

AppCacheEntry ReadCache(
        const std::string& section,
        const std::string& key)
{
    if (section.empty() || key.empty())
        return AppCacheEntry{};

    const auto& cache = ReadCacheSection(section);
    auto entry = cache.find(key);
    return entry != cache.end()
                   ? entry->second
                   : AppCacheEntry{std::string(), 0};
}

AppCacheSection ReadCacheSection(const std::string& section)
{
    const auto& cache = mvApplicationCache.find(section);
    return cache != mvApplicationCache.end()
        ? cache->second
        : AppCacheSection();
}

void ClearCache(const std::string& section)
{
    mvApplicationCache.erase(section);
}

void DeleteCache(const std::string& section, const std::string& key)
{
    auto cache = mvApplicationCache.find(section);
    if(cache == mvApplicationCache.end())
       return;

    cache->second.erase(key); 
}
{'fraction_non_alphanumeric': 0.12920592193808883, 'fraction_numerical': 0.0023553162853297443, 'mean_word_length': 3.033921302578019, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, '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': '2528346', 'n_tokens_mistral': 900, 'n_tokens_neox': 879, 'n_words': 203}