<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace pGina.Plugin.MySqlLogger
{
    class SessionCache
    {
        private Dictionary<int, string> m_cache;

        public SessionCache()
        {
            m_cache = new Dictionary<int, string>();
        }

        public void Add(int sessId, string userName)
        {
            lock(this)
            {
                if (!m_cache.ContainsKey(sessId))
                    m_cache.Add(sessId, userName);
                else
                    m_cache[sessId] = userName;
            }
        }

        public string Get(int sessId)
        {
            if (m_cache.ContainsKey(sessId))
                return m_cache[sessId];
            return "";
        }

        public void Clear()
        {
            lock (this)
            {
                m_cache.Clear();
            }
        }
    }
}<commit_msg>Add lock around Get in session cache, and add default "unknown" username.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace pGina.Plugin.MySqlLogger
{
    class SessionCache
    {
        private Dictionary<int, string> m_cache;

        public SessionCache()
        {
            m_cache = new Dictionary<int, string>();
        }

        public void Add(int sessId, string userName)
        {
            lock(this)
            {
                if (!m_cache.ContainsKey(sessId))
                    m_cache.Add(sessId, userName);
                else
                    m_cache[sessId] = userName;
            }
        }

        public string Get(int sessId)
        {
            string result = "--Unknown--";
            lock (this)
            {
                if (m_cache.ContainsKey(sessId))
                    result = m_cache[sessId];
            }
            return result;
        }

        public void Clear()
        {
            lock (this)
            {
                m_cache.Clear();
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.08957415565345081, 'fraction_numerical': 0.0, 'mean_word_length': 1.2560706401766004, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3740779', 'n_tokens_mistral': 571, 'n_tokens_neox': 546, 'n_words': 119}