コード例 #1
0
        public bool AddAccountData(string account_name, AccountData account_data)
        {
            this.RemoveAccountData(account_data.account_idx);

            CacheAccountData cache_chars = CommonObjectPools.Spawn <CacheAccountData>();

            cache_chars.logout_time  = Time.second_time;
            cache_chars.account_data = account_data;
            m_chache_account.Add(account_name, cache_chars);
            m_account_2_name.Add(account_data.account_idx, account_name);

            return(true);
        }
コード例 #2
0
        /// <summary>
        /// 释放超过多少天未登陆的数据
        /// </summary>
        private int ReleaseOffline(List <CacheAccountData> list, int day, int total_release)
        {
            int release_count = 0;

            for (int i = list.Count - 1; i >= 0 && release_count < total_release; --i)
            {
                CacheAccountData account_data = list[i];
                if (account_data.logout_time > 0 && (Time.second_time - account_data.logout_time >= Utils.Day2Second(day)))
                {
                    this.RemoveAccountData(account_data.account_data.account_idx);
                    list.RemoveAt(i);
                    ++release_count;
                }
            }
            return(release_count);
        }