static Cache()
        {
            STEM.Sys.Global.ThreadPool.BeginAsync(new ThreadStart(_TimeoutThread), TimeSpan.FromMinutes(5));

            lock (Cache._CacheObjects)
            {
                if (Cache._CacheObjects.Count == 0)
                {
                    if (Directory.Exists(CacheDirectory))
                    {
                        foreach (string file in Directory.GetFiles(CacheDirectory, "*.cache"))
                        {
                            try
                            {
                                SessionObject so = SessionObject.Deserialize(File.ReadAllText(file));

                                if (so != null)
                                {
                                    _CacheObjects[so.Key.ToUpper(System.Globalization.CultureInfo.CurrentCulture)] = so;
                                }
                            }
                            catch { }
                        }
                    }
                }
            }
        }
        public object this[string key]
        {
            get
            {
                if (String.IsNullOrEmpty(key))
                {
                    throw new ArgumentNullException(nameof(key));
                }

                try
                {
                    if (!_CacheObjects.ContainsKey(key.ToUpper(System.Globalization.CultureInfo.CurrentCulture)))
                    {
                        string file = Path.Combine(CacheDirectory, STEM.Sys.State.KeyManager.GetHash(key) + ".cache");
                        if (File.Exists(file))
                        {
                            try
                            {
                                SessionObject so = SessionObject.Deserialize(File.ReadAllText(file));

                                if (so != null)
                                {
                                    _CacheObjects[so.Key.ToUpper(System.Globalization.CultureInfo.CurrentCulture)] = so;
                                }
                            }
                            catch { }
                        }
                    }

                    if (_CacheObjects.ContainsKey(key.ToUpper(System.Globalization.CultureInfo.CurrentCulture)))
                    {
                        object ret = _CacheObjects[key.ToUpper(System.Globalization.CultureInfo.CurrentCulture)].Value;
                        return(ret);
                    }
                }
                catch { }

                return(null);
            }

            set
            {
                if (String.IsNullOrEmpty(key))
                {
                    throw new ArgumentNullException(nameof(key));
                }

                if (value == null)
                {
                    lock (_CacheObjects)
                        _CacheObjects.Remove(key.ToUpper(System.Globalization.CultureInfo.CurrentCulture));

                    try
                    {
                        if (File.Exists(Path.Combine(CacheDirectory, STEM.Sys.State.KeyManager.GetHash(key) + ".cache")))
                        {
                            File.Delete(Path.Combine(CacheDirectory, STEM.Sys.State.KeyManager.GetHash(key) + ".cache"));
                        }
                    }
                    catch { }
                }
                else
                {
                    lock (_CacheObjects)
                        _CacheObjects[key.ToUpper(System.Globalization.CultureInfo.CurrentCulture)] = new SessionObject(key, value);

                    try
                    {
                        File.WriteAllText(Path.Combine(CacheDirectory, STEM.Sys.State.KeyManager.GetHash(key) + ".cache"), _CacheObjects[key.ToUpper(System.Globalization.CultureInfo.CurrentCulture)].Serialize());
                    }
                    catch (Exception ex)
                    {
                        STEM.Sys.EventLog.WriteEntry("STEM.Sys.State.Cache", new Exception("Failed to write cache file for key (" + key + ")", ex));
                    }
                }
            }
        }