<commit_before>using System;
using System.ComponentModel.Composition;
using System.Globalization;
using System.Reactive;
using System.Reactive.Linq;
using Akavache;
using NLog;

namespace GitHub.Caches
{
    /// <summary>
    /// A cache for data that's not host specific
    /// </summary>
    [Export(typeof(ISharedCache))]
    [PartCreationPolicy(CreationPolicy.Shared)]
    public class SharedCache : ISharedCache
    {
        const string enterpriseHostApiBaseUriCacheKey = "enterprise-host-api-base-uri";
        static readonly Logger log = LogManager.GetCurrentClassLogger();

        static SharedCache()
        {
            try
            {
                BlobCache.ApplicationName = Info.ApplicationInfo.ApplicationName;
            }
            catch (Exception e)
            {
                log.Error("Error while running the static inializer for SharedCache", e);
            }
        }

        public SharedCache() : this(null, null, null)
        {
        }

        protected SharedCache(
            IBlobCache userAccountCache = null,
            IBlobCache localMachineCache = null,
            ISecureBlobCache secureCache = null)
        {
            
            if (secureCache == null)
            {
                try
                {
                    BlobCache.Secure = new CredentialCache();
                    secureCache = BlobCache.Secure;
                }
                catch (Exception e)
                {
                    log.Error("Failed to set up secure cache.", e);
                    secureCache = new InMemoryBlobCache();
                }
            }
            UserAccount = userAccountCache ?? GetBlobCacheWithFallback(() => BlobCache.UserAccount, "UserAccount");
            LocalMachine = localMachineCache ?? GetBlobCacheWithFallback(() => BlobCache.LocalMachine, "LocalMachine");
            Secure = secureCache;
        }

        public IBlobCache UserAccount { get; private set; }
        public IBlobCache LocalMachine { get; private set; }
        public ISecureBlobCache Secure { get; private set; }

        public IObservable<Uri> GetEnterpriseHostUri()
        {
            return UserAccount.GetObject<Uri>(enterpriseHostApiBaseUriCacheKey);
        }

        public IObservable<Unit> InsertEnterpriseHostUri(Uri enterpriseHostUri)
        {
            return UserAccount.InsertObject(enterpriseHostApiBaseUriCacheKey, enterpriseHostUri);
        }

        public IObservable<Unit> InvalidateEnterpriseHostUri()
        {
            return UserAccount.InvalidateObject<Uri>(enterpriseHostApiBaseUriCacheKey);
        }

        bool disposed;
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (disposed) return;

                UserAccount.Dispose();
                UserAccount.Shutdown.Wait();
                LocalMachine.Dispose();
                LocalMachine.Shutdown.Wait();
                Secure.Dispose();
                Secure.Shutdown.Wait();
                disposed = true;
            }
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        static IBlobCache GetBlobCacheWithFallback(Func<IBlobCache> blobCacheFunc, string cacheName)
        {
            try
            {
                return blobCacheFunc();
            }
            catch (Exception e)
            {
                log.Error(string.Format(CultureInfo.InvariantCulture, "Failed to set the {0} cache.", cacheName), e);
                return new InMemoryBlobCache();
            }
        }
    }
}
<commit_msg>Remove optionality of parameters<commit_after>using System;
using System.ComponentModel.Composition;
using System.Globalization;
using System.Reactive;
using System.Reactive.Linq;
using Akavache;
using NLog;

namespace GitHub.Caches
{
    /// <summary>
    /// A cache for data that's not host specific
    /// </summary>
    [Export(typeof(ISharedCache))]
    [PartCreationPolicy(CreationPolicy.Shared)]
    public class SharedCache : ISharedCache
    {
        const string enterpriseHostApiBaseUriCacheKey = "enterprise-host-api-base-uri";
        static readonly Logger log = LogManager.GetCurrentClassLogger();

        static SharedCache()
        {
            try
            {
                BlobCache.ApplicationName = Info.ApplicationInfo.ApplicationName;
            }
            catch (Exception e)
            {
                log.Error("Error while running the static inializer for SharedCache", e);
            }
        }

        public SharedCache() : this(null, null, null)
        {
        }

        protected SharedCache(IBlobCache userAccountCache, IBlobCache localMachineCache, ISecureBlobCache secureCache)
        {
            if (secureCache == null)
            {
                try
                {
                    BlobCache.Secure = new CredentialCache();
                    secureCache = BlobCache.Secure;
                }
                catch (Exception e)
                {
                    log.Error("Failed to set up secure cache.", e);
                    secureCache = new InMemoryBlobCache();
                }
            }
            UserAccount = userAccountCache ?? GetBlobCacheWithFallback(() => BlobCache.UserAccount, "UserAccount");
            LocalMachine = localMachineCache ?? GetBlobCacheWithFallback(() => BlobCache.LocalMachine, "LocalMachine");
            Secure = secureCache;
        }

        public IBlobCache UserAccount { get; private set; }
        public IBlobCache LocalMachine { get; private set; }
        public ISecureBlobCache Secure { get; private set; }

        public IObservable<Uri> GetEnterpriseHostUri()
        {
            return UserAccount.GetObject<Uri>(enterpriseHostApiBaseUriCacheKey);
        }

        public IObservable<Unit> InsertEnterpriseHostUri(Uri enterpriseHostUri)
        {
            return UserAccount.InsertObject(enterpriseHostApiBaseUriCacheKey, enterpriseHostUri);
        }

        public IObservable<Unit> InvalidateEnterpriseHostUri()
        {
            return UserAccount.InvalidateObject<Uri>(enterpriseHostApiBaseUriCacheKey);
        }

        bool disposed;
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (disposed) return;

                UserAccount.Dispose();
                UserAccount.Shutdown.Wait();
                LocalMachine.Dispose();
                LocalMachine.Shutdown.Wait();
                Secure.Dispose();
                Secure.Shutdown.Wait();
                disposed = true;
            }
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        static IBlobCache GetBlobCacheWithFallback(Func<IBlobCache> blobCacheFunc, string cacheName)
        {
            try
            {
                return blobCacheFunc();
            }
            catch (Exception e)
            {
                log.Error(string.Format(CultureInfo.InvariantCulture, "Failed to set the {0} cache.", cacheName), e);
                return new InMemoryBlobCache();
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.08151724137931035, 'fraction_numerical': 0.00027586206896551725, 'mean_word_length': 1.713697604790419, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, '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': '1196049', 'n_tokens_mistral': 1839, 'n_tokens_neox': 1757, 'n_words': 383}