Esempio n. 1
0
        /// <summary>
        /// Used to insert a new entry to the cache
        /// </summary>
        /// <typeparam name="V">Data type of Value</typeparam>
        /// <typeparam name="K">Data type of Key</typeparam>
        /// <param name="key">key</param>
        /// <param name="val">value</param>
        /// <param name="lifespaninMillis">Lifespan in milliseconds</param>
        /// <param name="maxIdleTimeinMillis">Maximum idle time in milliseconds</param>
        public void put <V, K>(K key, V val, int lifespaninMillis, int maxIdleTimeinMillis)
        {
            int          lifespanSecs = TimeSpan.FromMilliseconds(lifespaninMillis).Seconds;
            int          maxIdleSecs  = TimeSpan.FromMilliseconds(maxIdleTimeinMillis).Seconds;
            PutOperation op           = operationsFactory.newPutKeyValueOperation(serializer.serialize(key), serializer.serialize(val), lifespanSecs, maxIdleSecs);

            transport = transportFactory.getTransport();
            try
            {
                byte[] result = (byte[])op.executeOperation(transport);
            }
            finally
            {
                transportFactory.releaseTransport(transport);
            }
        }
Esempio n. 2
0
        public void executeOperationTest()
        {
            Transport trans = new TCPTransport(System.Net.IPAddress.Loopback, 11222);
            Codec codec = new Codec();
            Serializer s = new DefaultSerializer();
            Serializer s2 = new DefaultSerializer();

            //byte[] key = s.serialize("11");
            byte[] key = s.serialize("key15");
            //byte[] key=UTF8Encoding.UTF8.GetBytes("key10");
            byte[] val = s.serialize("hexachlorocyclohexane777");//UTF8Encoding.UTF8.GetBytes("hexachlorocyclohexane777");
            PutOperation target = new PutOperation(codec, key, null, 0, null, val, 0, 0); // TODO: Initialize to an appropriate value
            Transport transport = trans;

            byte[] expected = null; // TODO: Initialize to an appropriate value
            byte[] actual;
            actual = target.executeOperation(transport);
            Assert.AreEqual(expected, actual);
        }
Esempio n. 3
0
        public void executeOperationTest()
        {
            Transport  trans = new TCPTransport(System.Net.IPAddress.Loopback, 11222);
            Codec      codec = new Codec();
            Serializer s     = new DefaultSerializer();
            Serializer s2    = new DefaultSerializer();


            //byte[] key = s.serialize("11");
            byte[] key = s.serialize("key15");
            //byte[] key=UTF8Encoding.UTF8.GetBytes("key10");
            byte[]       val       = s.serialize("hexachlorocyclohexane777");                //UTF8Encoding.UTF8.GetBytes("hexachlorocyclohexane777");
            PutOperation target    = new PutOperation(codec, key, null, 0, null, val, 0, 0); // TODO: Initialize to an appropriate value
            Transport    transport = trans;

            byte[] expected = null; // TODO: Initialize to an appropriate value
            byte[] actual;
            actual = target.executeOperation(transport);
            Assert.AreEqual(expected, actual);
        }