Пример #1
0
 private async Task <List <T> > GetReportWithCacheAsync <T>(
     int count,
     ReportCache <T> cache,
     Func <SQLiteConnection, SQLiteTransaction, Task <List <T> > > funcAsync)
 {
     return(await cache.GetValueAsync(count, () => ExecuteQueryAsync(funcAsync)));
 }
Пример #2
0
        /// <summary>
        /// Конструктор класса базы данных
        /// </summary>
        /// <param name="dataSource">Путь к базе данных</param>
        /// <param name="cacheTime">Время актуальности значений в кэше в секундах</param>
        /// <param name="maxCountItemsInReport">Максимальное количество элементов в отчете Reports</param>
        public Database(string dataSource, int cacheTime, int maxCountItemsInReport)
        {
            this.maxCountItemsInReport = maxCountItemsInReport;

            connectionString =
                new SQLiteConnectionStringBuilder
            {
                DataSource     = dataSource,
                Version        = 3,
                SyncMode       = SynchronizationModes.Normal,
                JournalMode    = SQLiteJournalModeEnum.Wal,
                DateTimeKind   = DateTimeKind.Utc,
                DateTimeFormat = SQLiteDateFormats.ISO8601
            }.ConnectionString;

            recentMathcesCache  = new ReportCache <Match>(cacheTime);
            bestPlayersCache    = new ReportCache <BestPlayer>(cacheTime);
            popularServersCache = new ReportCache <PopularServer>(cacheTime);
            serverStatCache     = new StatsCache <ServerStat>(cacheTime);
            playerStatCache     = new StatsCache <PlayerStat>(cacheTime);

            Init();
        }