[TestMethod] // Debug this method to be able to see debug output etc.
        public async Task CreateDbs()
        {
            try
            {
                await InitApp();

                //var db = new SAFEDataWriter(_app.AppId, session);

                var dbCount = 0;
                while (true)
                {
                    try
                    {
                        var dbId = GetRandomString(15);
                        await _db.CreateDbAsync(dbId); // this is the original operation

                        //await db.Write_17(dbId); // Write_1 - Write_17 will execute one additional operation per method, from CreateDbAsync. Write_17 will do the same as CreateDbAsync.
                        Debug.WriteLine(++dbCount); // so we expect to reach ~1285 iterations on Write_1 and about 50 iterations on Write_17
                        await Task.Delay(1);
                    }
                    catch (Exception ex)
                    { }
                }
            }
            catch (Exception ex)
            { }
        }
Ejemplo n.º 2
0
        void CheckCache(string streamKey)
        {
            lock (_accessLock)
            {
                if (!_cache.TryGetValue(streamKey, out object data))
                {
                    // create db if not exists
                    var dbs = _store.GetDatabaseIdsAsync().GetAwaiter().GetResult();
                    if (!dbs.Any(d => d.Name == _databaseId))
                    {
                        _store.CreateDbAsync(_databaseId).GetAwaiter().GetResult();
                    }

                    _cache[streamKey] = new object();
                }
            }
        }