public override Task <GetWorkerResponse> Get(GetWorkerRequest request, ServerCallContext context)
        {
            this.faster.StartSession();
            this.headers.StartSession();

            var result = new GetWorkerResponse();
            var hits   = 0;

            foreach (var key in request.Key)
            {
                var x = new Common.KeyValuePair()
                {
                    Key   = key,
                    Value = ByteString.Empty
                };

                //first lets figure out if the key exists and stil valid
                var k = new KeyHeader();

                var v = new ValueHeader();

                var o = new KeyHeader();

                k.key = key;

                headers.Read(ref k, ref o, ref v, default, 0);
Exemplo n.º 2
0
        private static SetRequest SetPRequest(string key)
        {
            var rq   = new SetRequest();
            var pair = new Common.KeyValuePair
            {
                Key   = key,
                Value = ByteString.Empty
            };

            rq.Pairs.Add(pair);

            return(rq);
        }
Exemplo n.º 3
0
        private static Caching.Faster.Proxy.SetRequest SetPRequest(string key, string value)
        {
            var rq   = new SetRequest();
            var pair = new Common.KeyValuePair
            {
                Key   = key,
                Ttl   = 15,
                Value = ByteString.CopyFrom(Encoding.UTF8.GetBytes(value))
            };

            rq.Pairs.Add(pair);

            return(rq);
        }
Exemplo n.º 4
0
        //private static Task run2(Caching.Faster.Cache.CacheClient client)
        //{
        //    Console.WriteLine("Starting");
        //    int success = 0;
        //    int notok = 0;
        //    var k = new List<string>();
        //    var sw = new Stopwatch();
        //    sw.Start();
        //    for (int i = 0; i < 100; i++)
        //    {
        //        var g = Guid.NewGuid().ToString();

        //        k.Add(g);
        //        client.Set(SetRequest(g, "hola mundo"));
        //        if (i % 1000 == 0)
        //        {
        //            Console.WriteLine($"{sw.ElapsedMilliseconds} about {sw.ElapsedMilliseconds / 1000}ms each");
        //            sw.Restart();
        //        }
        //    }
        //    for (int i = 0; i < 100; i++)
        //    {
        //        var r = client.Get(GetRequest(k[i]));
        //        if (r.Results[0].Value != null)
        //        {
        //            success++;
        //        }
        //        else
        //        {
        //            notok++;
        //        }
        //        if (i % 1000 == 0)
        //        {
        //            Console.WriteLine($"{sw.ElapsedMilliseconds} about {sw.ElapsedMilliseconds / 1000}ms each");
        //            sw.Restart();
        //        }
        //    }
        //    Console.WriteLine($"Ok {success}:{notok} ");
        //    return Task.CompletedTask;
        //}
        private static SetWorkerRequest SetRequest(string key, string value)
        {
            var rq   = new SetWorkerRequest();
            var pair = new Common.KeyValuePair
            {
                Key   = key,
                Ttl   = Convert.ToInt32(TimeSpan.Parse("00:10:00").TotalSeconds),
                Value = ByteString.CopyFrom(Encoding.UTF8.GetBytes(value))
            };

            rq.Pairs.Add(pair);

            return(rq);
        }