예제 #1
0
        public async Task <DatabaseObjectEntry> BigDB(string table, string key)
        {
            var client = await _clientProvider.Obtain().ConfigureAwait(false);

            var dbo = await client.DownloadObject(table, key).ConfigureAwait(false);

            return(dbo.ToObjectEntry());
        }
예제 #2
0
        public async Task <OwnedMemory> Username(string simpleId)
        {
            HttpContext.Response.ContentType = "application/json";

            // TODO: allow FileCache to not have any timeout for caching
            // because usernames & simpleids never change
            var username = await _cache.TryRead($"usernames.[{simpleId}]", async() =>
            {
                var client = await _clientProvider.Obtain().ConfigureAwait(false);
                var dbo    = await client.QuerySingle("Usernames", "owner", simpleId).ConfigureAwait(false);

                var result = new UsernameLookup
                {
                    SimpleId = simpleId,
                    Username = dbo.Key,
                };

                var serialized = System.Text.Json.JsonSerializer.Serialize(result);
                return(Encoding.UTF8.GetBytes(serialized));
            }).ConfigureAwait(false);

            return(username);
        }