static async Task <World[]> GetUncachedRows(int id, int i, int count, RawDb rawdb, World[] result) { using (var db = new NpgsqlConnection(rawdb._connectionString)) { await db.OpenAsync(); var(cmd, idParameter) = rawdb.CreateReadCommand(db); using (cmd) { Func <ICacheEntry, Task <CachedWorld> > create = async(entry) => { return(await rawdb.ReadSingleRow(cmd)); }; var cacheKeys = _cacheKeys; var key = cacheKeys[id]; idParameter.TypedValue = id; for (; i < result.Length; i++) { var data = await rawdb._cache.GetOrCreateAsync <CachedWorld>(key, create); result[i] = data; id = rawdb._random.Next(1, 10001); idParameter.TypedValue = id; key = cacheKeys[id]; } } } return(result); }
static async Task <World[]> LoadUncachedQueries(int id, int i, int count, RawDb rawdb, World[] result) { using (var db = new NpgsqlConnection(_connectionString)) { await db.OpenAsync(); Func <ICacheEntry, Task <CachedWorld> > create = async(entry) => { return(await rawdb.ReadSingleRow(db, rawdb.SingleCommand)); }; var cacheKeys = _cacheKeys; var key = cacheKeys[id]; rawdb.SingleCommand.Connection = db; rawdb.mID.TypedValue = id; for (; i < result.Length; i++) { var data = await _cache.GetOrCreateAsync <CachedWorld>(key, create); result[i] = data; id = rawdb._random.Next(1, 10001); rawdb.SingleCommand.Connection = db; rawdb.mID.TypedValue = id; key = cacheKeys[id]; } } return(result); }
public HttpHandler() { mPgsql = new RawDb(new ConcurrentRandom(), Npgsql.NpgsqlFactory.Instance); }
static async Task <World[]> LoadUncachedQueries(int id, int i, int count, RawDb rawdb, World[] result) { using (var db = await DBConnectionGroupPool.Pop()) { Func <ICacheEntry, Task <CachedWorld> > create = async(entry) => { return(await rawdb.ReadSingleRow(db.Connection, rawdb.SingleCommand)); }; var cacheKeys = _cacheKeys; var key = cacheKeys[id]; rawdb.SingleCommand.Connection = db.Connection; rawdb.SingleCommand.Parameters[0].Value = id; for (; i < result.Length; i++) { var data = await _cache.GetOrCreateAsync <CachedWorld>(key, create); result[i] = data; id = rawdb._random.Next(1, 10001); rawdb.SingleCommand.Connection = db.Connection; rawdb.SingleCommand.Parameters[0].Value = id; key = cacheKeys[id]; } } return(result); }
private async Task SingleQuery(PipeWriter pipeWriter) { OutputSingleQuery(pipeWriter, await RawDb.LoadSingleQueryRow()); }
private async Task MultipleQueries(PipeWriter pipeWriter, int count) { OutputMultipleQueries(pipeWriter, await RawDb.LoadMultipleQueriesRows(count)); }
private async Task Updates(PipeWriter pipeWriter, int count) { OutputUpdates(pipeWriter, await RawDb.LoadMultipleUpdatesRows(count)); }
private async Task FortunesRaw(PipeWriter pipeWriter) { OutputFortunes(pipeWriter, await RawDb.LoadFortunesRows()); }
private async Task Caching(PipeWriter pipeWriter, int count) { OutputMultipleQueries(pipeWriter, await RawDb.LoadCachedQueries(count)); }