예제 #1
0
        public ClusterFixture()
        {
            _redis = new RedisInside.Redis();
            Console.WriteLine(_redis.Endpoint.ToString());

            Console.WriteLine("Initializing Orleans TestCluster");
            var builder = new TestClusterBuilder(1);

            builder.Options.ServiceId = "Service";
            builder.Options.ClusterId = "TestCluster";
            builder.AddSiloBuilderConfigurator <SiloConfigurator>();
            builder.AddClientBuilderConfigurator <ClientConfigurator>();

            //this is one of the only ways to be able to pass data (the redis connection string) to the silo(s) that TestCluster will startup
            builder.ConfigureHostConfiguration(config =>
            {
                config.AddInMemoryCollection(new Dictionary <string, string>()
                {
                    { nameof(RedisInside.Redis), _redis.Endpoint.ToString() }
                });
            });

            Cluster = builder.Build();

            Cluster.Deploy();
            Cluster.InitializeClient();
            Client = Cluster.Client;

            var redisOptions = ConfigurationOptions.Parse(_redis.Endpoint.ToString());
            var connection   = ConnectionMultiplexer.ConnectAsync(redisOptions).Result;

            Database = connection.GetDatabase();
            Console.WriteLine("Initialized Orleans TestCluster");
        }
예제 #2
0
        static void Main(string[] args)
        {
            RedisInstance = new Redis(cfg => {
                cfg.Port(8096);
                cfg.LogTo(new Action<string>((s) => Console.WriteLine(s)));
            });

            var client = new RedisClient(RedisInstance.Endpoint.ToString());
            var patientClient = client.As<Patient>();

            var patient = new Patient
            {
                Name = "Scott",
                Codes = new List<string> { "1.1", "2.2" }
            };
            patient.Id = patientClient.GetNextSequence();
            patientClient.Store(patient);

            var retrievedPatient = patientClient.GetById(patient.Id);
            Console.WriteLine("{0}:{1}", retrievedPatient.Id, retrievedPatient.Name);

            Console.ReadKey();
        }