Esempio n. 1
0
        public string GetUsername(long uid)
        {
            lock (CachedData)
            {
                if (CachedData.TryGetValue(uid, out var cachedData))
                {
                    if (DateTime.UtcNow - cachedData.LastUpdate >
                        new TimeSpan(3, 0, 0, 0))
                    {
                        return(null);
                    }
                    return(cachedData.Username);
                }
                else
                {
                    return(null);
                }

                //try
                //{
                //    return CachedData[uid].Username;
                //    CachedData.TryGetValue
                //}
                //catch (KeyNotFoundException)
                //{
                //    return null;
                //}
            }
        }