protected void TestPutRemoveContains(IRemoteCache <string, string> cache) { cache.Put(K1, V1); Assert.IsTrue(cache.ContainsKey(K1)); cache.Remove(K1); Assert.IsFalse(cache.ContainsKey(K1)); }
public void ContainsKeyTest() { String key = UniqueKey.NextKey(); Assert.IsFalse(cache.ContainsKey(key)); cache.Put(key, "oxygen"); Assert.IsTrue(cache.ContainsKey(key)); }
protected void TestPutRemoveAsyncContains(IRemoteCache <string, string> cache) { cache.Put(K1, V1); Assert.IsTrue(cache.ContainsKey(K1)); Task <string> result = cache.RemoveAsync(K1); result.Wait(5000); Assert.IsFalse(cache.ContainsKey(K1)); }
public void BeforeClass() { ConfigurationBuilder conf = new ConfigurationBuilder(); conf.AddServer().Host("127.0.0.1").Port(11222); conf.ConnectionTimeout(90000).SocketTimeout(6000); conf.Marshaller(new BasicTypesProtoStreamMarshaller()); remoteManager = new RemoteCacheManager(conf.Build(), true); IRemoteCache <String, String> metadataCache = remoteManager.GetCache <String, String>(PROTOBUF_METADATA_CACHE_NAME); metadataCache.Remove(ERRORS_KEY_SUFFIX); metadataCache.Put("sample_bank_account/bank.proto", File.ReadAllText("proto2/bank.proto")); if (metadataCache.ContainsKey(ERRORS_KEY_SUFFIX)) { Assert.Fail("fail: error in registering .proto model"); } remoteManager.Administration().CreateCacheWithXml <object, object>(NAMED_CACHE, "<infinispan><cache-container><distributed-cache name=\"" + NAMED_CACHE + "\">" + " <indexing> " + " <indexed-entities> " + " <indexed-entity>sample_bank_account.User</indexed-entity>" + " <indexed-entity>sample_bank_account.Transaction</indexed-entity>" + " </indexed-entities>" + " </indexing> " + " </distributed-cache> " + " </cache-container></infinispan>"); IRemoteCache <String, Transaction> transactionCache = remoteManager.GetCache <String, Transaction>(NAMED_CACHE); Assert.NotNull(transactionCache); PutTransactions(transactionCache); }
public void BeforeClass() { ConfigurationBuilder conf = new ConfigurationBuilder(); conf.AddServer().Host("127.0.0.1").Port(11222); conf.ConnectionTimeout(90000).SocketTimeout(6000); conf.Marshaller(new BasicTypesProtoStreamMarshaller()); remoteManager = new RemoteCacheManager(conf.Build(), true); IRemoteCache <String, String> metadataCache = remoteManager.GetCache <String, String>(PROTOBUF_METADATA_CACHE_NAME); metadataCache.Clear(); metadataCache.Put("sample_bank_account/bank.proto", File.ReadAllText("proto2/bank.proto")); if (metadataCache.ContainsKey(ERRORS_KEY_SUFFIX)) { Assert.Fail("fail: error in registering .proto model"); } IRemoteCache <int, User> userCache = remoteManager.GetCache <int, User>(NAMED_CACHE); userCache.Clear(); PutUsers(userCache); IRemoteCache <int, Account> accountCache = remoteManager.GetCache <int, Account>(NAMED_CACHE); PutAccounts(accountCache); IRemoteCache <int, Transaction> transactionCache = remoteManager.GetCache <int, Transaction>(NAMED_CACHE); PutTransactions(transactionCache); }
static void Main(string[] args) { RemoteCacheManager remoteManager; const string ERRORS_KEY_SUFFIX = ".errors"; const string PROTOBUF_METADATA_CACHE_NAME = "___protobuf_metadata"; ConfigurationBuilder builder = new ConfigurationBuilder(); builder.AddServer() .Host(args.Length > 1 ? args[0] : "127.0.0.1") .Port(args.Length > 2 ? int.Parse(args[1]) : 11222); builder.Marshaller(new BasicTypesProtoStreamMarshaller()); remoteManager = new RemoteCacheManager(builder.Build(), true); IRemoteCache <String, String> metadataCache = remoteManager.GetCache <String, String>(PROTOBUF_METADATA_CACHE_NAME); IRemoteCache <int, Person> testCache = remoteManager.GetCache <int, Person>("namedCache"); // Installing the entities model into the Infinispan __protobuf_metadata cache metadataCache.Put("sample_person/person.proto", File.ReadAllText("../../resources/proto2/person.proto")); // Console.WriteLine(File.ReadAllText("../../resources/proto2/person.proto")); if (metadataCache.ContainsKey(ERRORS_KEY_SUFFIX)) { Console.WriteLine("fail: error in registering .proto model"); Environment.Exit(-1); } testCache.Clear(); // Fill the application cache putPersons(testCache); // Run a query QueryRequest qr = new QueryRequest(); qr.JpqlString = "from quickstart.Person where surname like '%ou%'"; QueryResponse result = testCache.Query(qr); List <Person> listOfUsers = new List <Person>(); unwrapResults(result, listOfUsers); Console.WriteLine("There are " + listOfUsers.Count + " Users:"); foreach (Person user in listOfUsers) { Console.WriteLine(user.ToString()); System.Threading.Thread.Sleep(1000); } System.Threading.Thread.Sleep(5000); }
protected void TestContainsKey(IRemoteCache <string, string> cache) { Assert.IsFalse(cache.ContainsKey(NON_EXISTENT_KEY)); }
/* * public void BeforeClass() * { * IRemoteCache<int, User> userCache = remoteManager.GetCache<int, User>(NAMED_CACHE); * userCache.Clear(); * PutUsers(userCache); * IRemoteCache<int, Account> accountCache = remoteManager.GetCache<int, Account>(NAMED_CACHE); * PutAccounts(accountCache); * IRemoteCache<int, Transaction> transactionCache = remoteManager.GetCache<int, Transaction>(NAMED_CACHE); * PutTransactions(transactionCache); */ static void Main() { // Create a configuration for a locally-running server ConfigurationBuilder conf = new ConfigurationBuilder(); conf.AddServer().Host("127.0.0.1").Port(11222); conf.ConnectionTimeout(90000).SocketTimeout(6000); conf.Marshaller(new BasicTypesProtoStreamMarshaller()); RemoteCacheManager remoteManager = new RemoteCacheManager(conf.Build(), true); IRemoteCache <String, String> metadataCache = remoteManager.GetCache <String, String>(PROTOBUF_METADATA_CACHE_NAME); metadataCache.Put("quickstart/addressbook.proto", File.ReadAllText("addressbook.proto")); if (metadataCache.ContainsKey(ERRORS_KEY_SUFFIX)) { Console.WriteLine("fail: error in registering .proto model"); Environment.Exit(-1); } IRemoteCache <int, Person> cache = remoteManager.GetCache <int, Person>(NAMED_CACHE); bool quit = false; displayActions(); while (!quit) { int action = readAction(); switch (action) { case 1: putPerson(cache); break; case 2: removePerson(cache); break; case 3: addPhone(cache); break; case 4: removePhone(cache); break; case 5: queryPersonByName(cache); break; case 6: queryPersonByPhone(cache); break; case 7: addMemo(cache); break; case 8: fullTextOnMemo(cache); break; case 9: projectAllNames(cache); break; case 10: countByDepartment(cache); break; case 11: printAll(cache); break; case 12: cache.Clear(); Console.WriteLine("Cache cleared"); break; case 13: quit = true; Console.WriteLine("Bye!"); break; case 0: displayActions(); break; default: Console.Error.WriteLine("Invalid action: " + action); break; } } remoteManager.Stop(); }