Ejemplo n.º 1
0
        /// <summary>
        /// Initializes account balance.
        /// </summary>
        private static void InitAccounts(ICacheClient <int, Account> cache)
        {
            // Clean up caches on all nodes before run.
            cache.Clear();

            // Initialize.
            cache.Put(1, new Account(1, 100));
            cache.Put(2, new Account(2, 200));

            Console.WriteLine();
            Console.WriteLine(">>> Accounts before transfer: ");
            Console.WriteLine(">>>     " + cache.Get(1));
            Console.WriteLine(">>>     " + cache.Get(2));
            Console.WriteLine();
        }
Ejemplo n.º 2
0
        public void AllKeyBasedOperations_PrimitiveKeyType_RequestIsRoutedToPrimaryNode(int key, int gridIdx)
        {
            int unused;

            TestOperation(() => _cache.Get(key), gridIdx);
            TestAsyncOperation(() => _cache.GetAsync(key), gridIdx);

            TestOperation(() => _cache.TryGet(key, out unused), gridIdx);
            TestAsyncOperation(() => _cache.TryGetAsync(key), gridIdx);

            TestOperation(() => _cache.Put(key, key), gridIdx, "Put");
            TestAsyncOperation(() => _cache.PutAsync(key, key), gridIdx, "Put");

            TestOperation(() => _cache.PutIfAbsent(key, key), gridIdx, "PutIfAbsent");
            TestAsyncOperation(() => _cache.PutIfAbsentAsync(key, key), gridIdx, "PutIfAbsent");

            TestOperation(() => _cache.GetAndPutIfAbsent(key, key), gridIdx, "GetAndPutIfAbsent");
            TestAsyncOperation(() => _cache.GetAndPutIfAbsentAsync(key, key), gridIdx, "GetAndPutIfAbsent");

            TestOperation(() => _cache.Clear(key), gridIdx, "ClearKey");
            TestAsyncOperation(() => _cache.ClearAsync(key), gridIdx, "ClearKey");

            TestOperation(() => _cache.ContainsKey(key), gridIdx, "ContainsKey");
            TestAsyncOperation(() => _cache.ContainsKeyAsync(key), gridIdx, "ContainsKey");

            TestOperation(() => _cache.GetAndPut(key, key), gridIdx, "GetAndPut");
            TestAsyncOperation(() => _cache.GetAndPutAsync(key, key), gridIdx, "GetAndPut");

            TestOperation(() => _cache.GetAndReplace(key, key), gridIdx, "GetAndReplace");
            TestAsyncOperation(() => _cache.GetAndReplaceAsync(key, key), gridIdx, "GetAndReplace");

            TestOperation(() => _cache.GetAndRemove(key), gridIdx, "GetAndRemove");
            TestAsyncOperation(() => _cache.GetAndRemoveAsync(key), gridIdx, "GetAndRemove");

            TestOperation(() => _cache.Replace(key, key), gridIdx, "Replace");
            TestAsyncOperation(() => _cache.ReplaceAsync(key, key), gridIdx, "Replace");

            TestOperation(() => _cache.Replace(key, key, key + 1), gridIdx, "ReplaceIfEquals");
            TestAsyncOperation(() => _cache.ReplaceAsync(key, key, key + 1), gridIdx, "ReplaceIfEquals");

            TestOperation(() => _cache.Remove(key), gridIdx, "RemoveKey");
            TestAsyncOperation(() => _cache.RemoveAsync(key), gridIdx, "RemoveKey");

            TestOperation(() => _cache.Remove(key, key), gridIdx, "RemoveIfEquals");
            TestAsyncOperation(() => _cache.RemoveAsync(key, key), gridIdx, "RemoveIfEquals");
        }
Ejemplo n.º 3
0
 public void Clear()
 {
     httpCacheClient.Clear(string.Empty);
 }