Example #1
0
        private static async Task StartSend(IDistributedCacheClient <byte[], byte[]> client, int messages_per_thread, CancellationToken token)
        {
            var seed = 0;

            while (true)
            {
                var now   = DateTime.UtcNow;
                var count = await Send(client, messages_per_thread, seed, token);

                Console.WriteLine($"Receive {count} keys after: {(DateTime.UtcNow - now).TotalSeconds} sec");
                seed += 256;
            }
        }
Example #2
0
        private static async Task <int> Send(IDistributedCacheClient <byte[], byte[]> client, int messages_per_thread, int seed, CancellationToken token)
        {
            var now       = DateTime.UtcNow;
            var requested = new Dictionary <byte[], DateTime>(new ByteArrayComparer());
            var comparer  = new ByteArrayComparer();
            var rand      = new Random(seed);

            for (var i = 0; i < messages_per_thread; i++)
            {
                var key = CreateId(rand);
                if (client.TryGet(key, out var data, out var expired) && !expired)
                {
                    requested.Remove(key, out var _);
                }