Example #1
0
        public async Task dtStringMsgPack(string input)
        {
            var key = $"datatypes:{DateTime.UtcNow:yyyy-MM-dd}:stringmessagepack";

            _ = await _redisCacheSvc.db.KeyDeleteAsync(key);

            var objOut  = new MyObj($"{input} {DateTime.UtcNow}");
            var jsonOut = objOut.ToMessagePack();

            _ = await _redisCacheSvc.db.StringSetAsync(key, jsonOut);

            var result = await _redisCacheSvc.db.StringGetAsync(key);

            Assert.Equal(jsonOut.Length, result.Length());
            Assert.Equal(objOut, result.FromMessagePack <MyObj>());
        }
Example #2
0
        public async Task DataTypeMessagePack()
        {
            var _redisCacheSvc = _serviceProvider.GetRequiredService <RedisCacheService>();
            var key            = $"datatypes:{DateTime.UtcNow:yyyy-MM-dd}:stringmessagepack";
            var obj            = new MyObj($"hello world! {DateTime.UtcNow}");

            for (var i = 0; i < 10_000; i++)
            {
                _ = await _redisCacheSvc.db.KeyDeleteAsync(key);

                _ = await _redisCacheSvc.db.StringSetAsync(key, obj.ToMessagePack());

                var result = await _redisCacheSvc.db.StringGetAsync(key);

                _ = result.FromMessagePack <MyObj>();
            }
        }