예제 #1
0
        /// <summary>
        /// Gets bulk data from the cache
        /// </summary>
        /// <typeparam name="K">Key</typeparam>
        /// <typeparam name="V">Value</typeparam>
        /// <param name="size">Number of records</param>
        /// <returns>Dictionary of retrieved data</returns>
        public Dictionary <K, V> getBulk <K, V>(int size)
        {
            transport = transportFactory.getTransport();
            BulkGetOperation            op = operationsFactory.newBulkGetOperation(size);
            Dictionary <byte[], byte[]> result;

            try
            {
                result = op.executeOperation(transport);
            }
            finally
            {
                transportFactory.releaseTransport(transport);
            }
            Dictionary <K, V> toReturn = new Dictionary <K, V>();

            for (int i = 0; i < result.Count; i++)
            {
                V val = (V)serializer.deserialize(result.ElementAt(i).Value);
                K key = (K)serializer.deserialize(result.ElementAt(i).Key);
                toReturn.Add(key, val);
            }
            return(toReturn);
        }