Exemplo n.º 1
0
            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);
            }
Exemplo n.º 2
0
            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);
            }
Exemplo n.º 3
0
            static async Task <World[]> LoadUncachedQueries(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));
                        };

                        idParameter.TypedValue = id;

                        for (; i < result.Length; i++)
                        {
                            var data = await rawdb._cache.GetOrCreateAsync <CachedWorld>(id, create);

                            result[i] = data;

                            id = rawdb._random.Next(1, 10001);
                            idParameter.TypedValue = id;
                        }
                    }
                }

                return(result);
            }
Exemplo n.º 4
0
            static async Task <CachedWorld[]> LoadUncachedQueries(int id, int i, int count, RawDb rawdb, CachedWorld[] result)
            {
                using (var db = new MySqlConnection(rawdb._connectionString))
                {
                    await db.OpenAsync();

                    var(cmd, idParameter) = await rawdb.CreateReadCommandAsync(db);

                    using (cmd)
                    {
                        Func <ICacheEntry, Task <CachedWorld> > create = async(entry) =>
                        {
                            return(await rawdb.ReadSingleRow(cmd));
                        };

                        var cacheKeys = _cacheKeys;
                        var key       = cacheKeys[id];

                        idParameter.Value = id;

                        for (; i < result.Length; i++)
                        {
                            result[i] = await rawdb._cache.GetOrCreateAsync <CachedWorld>(key, create);

                            id = rawdb._random.Next(1, 10001);
                            idParameter.Value = id;
                            key = cacheKeys[id];
                        }
                    }
                }

                return(result);
            }