Exemplo n.º 1
0
 public override void OneTimeSetUp()
 {
     _connection           = ConnectionMultiplexer.Connect(ConfigurationOptions.Parse(RedisConnectionOptions));
     _cacheType1           = new RedisIndexedStore <TestType1Entity>(_connection, new JsonSerializer(), entity => entity.Id, new[] { IndexDefinition <TestType1Entity> .CreateUniqueFromExtractor("name", e => e.Name) }, null);
     _cacheType2           = new RedisIndexedStore <TestType2Entity>(_connection, new JsonSerializer(), entity => entity.Id, new[] { IndexDefinition <TestType2Entity> .CreateUniqueFromExtractor("name", e => e.Name) }, null);
     _cacheType1WithExpiry = new RedisIndexedStore <TestType1Entity>(_connection, new JsonSerializer(), entity => entity.Id, new[] { IndexDefinition <TestType1Entity> .CreateUniqueFromExtractor("name", e => e.Name) }, TimeSpan.FromSeconds(1));
 }
        public async Task OneTimeSetUp()
        {
            _multiplexer = ConnectionMultiplexer.Connect(ConfigurationOptions.Parse(RedisConnectionOptions));

            await _server.Start();

            _multiplexer = ConnectionMultiplexer.Connect(ConfigurationOptions.Parse(RedisConnectionOptions));

            _cacheType1 = new RedisIndexedStore <TestCompany>(
                new RedisTestDatabaseConnector(_multiplexer),
                new DefaultJsonSerializer(),
                new CollectionWithIndexesSettings <TestCompany>
            {
                MasterKeyExtractor = new TestCompanyKeyExtractor(),
                Indexes            = new[]
                {
                    new IndexSettings <TestCompany>
                    {
                        Extractor   = new TestCompanyNameExtractor(),
                        Unique      = true,
                        WithPayload = true
                    },
                    new IndexSettings <TestCompany>
                    {
                        Extractor   = new TestCompanyCategoryExtractor(),
                        Unique      = false,
                        WithPayload = true
                    }
                }
            }
                );


            _cacheType2 = new RedisIndexedStore <TestPerson>(
                new RedisTestDatabaseConnector(_multiplexer),
                new DefaultJsonSerializer(),
                new CollectionWithIndexesSettings <TestPerson>
            {
                MasterKeyExtractor = new TestPersonKeyExtractor(),
                Indexes            = new[]
                {
                    new IndexSettings <TestPerson>
                    {
                        Extractor   = new TestPersonNameExtractor(),
                        Unique      = true,
                        WithPayload = true
                    },
                    new IndexSettings <TestPerson>
                    {
                        Extractor   = new TestPersonEmployerSectorExtractor(),
                        Unique      = false,
                        WithPayload = true
                    }
                }
            }
                );
        }