public async Task dtStringJson(string input) { var key = $"datatypes:{DateTime.UtcNow:yyyy-MM-dd}:stringjson"; _ = await _redisCacheSvc.db.KeyDeleteAsync(key); var objOut = new MyObj($"{input} {DateTime.UtcNow}"); var jsonOut = objOut.ToJSON(); _ = await _redisCacheSvc.db.StringSetAsync(key, jsonOut); var result = await _redisCacheSvc.db.StringGetAsync(key); Assert.Equal(jsonOut, result); Assert.Equal(objOut, result.FromJSON <MyObj>()); }
public async Task DataTypeJson() { var _redisCacheSvc = _serviceProvider.GetRequiredService <RedisCacheService>(); var key = $"datatypes:{DateTime.UtcNow:yyyy-MM-dd}:stringjson"; var obj = new MyObj($"hello world! {DateTime.UtcNow}"); for (var i = 0; i < maxIterations; i++) { _ = await _redisCacheSvc.db.KeyDeleteAsync(key); _ = await _redisCacheSvc.db.StringSetAsync(key, obj.ToJSON()); var result = await _redisCacheSvc.db.StringGetAsync(key); _ = result.FromJSON <MyObj>(); } }