protected override void ConfigureApplicationContainer(TinyIoCContainer container) { base.ConfigureApplicationContainer(container); var loggingService = new StringBuilderLoggingService(); container.Register <ILoggingService>((c, p) => loggingService); // Cache Level 1 - In Memory ICacheProvider l1Cache = new InMemoryCacheProvider( new MemoryCache("In-Memory Cache"), loggingService); // Cache Level 2 - Redis ICacheProvider l2Cache = new RedisCacheProvider( ConfigurationManager.AppSettings["RedisHost"], loggingService, new LoggingOptions { LogCacheMisses = true, LogCacheHits = true }); l2Cache.Delete("Test-Cache-Key"); container.Register <IDataService>(new DataService( loggingService, new[] { l1Cache, l2Cache })); }
static void Main(string[] args) { var provider = new InMemoryCacheProvider(); var r = new CachedRepository(provider); r.Add(new Customer(1, "Joe", "Vella")); r.Add(new Customer(2, "George", "Vella")); r.Add(new Customer(3, "Tatiana", "Camenzuli")); var id = GetCustomerId(r, "Joe"); var id2 = GetCustomerId(r, "George"); var id3 = GetCustomerId(r, new List<string>() { "George" }); var id4 = GetCustomerId(r, new[] { "Joe" }); //var allSalesByJoe1 = query1.Where(x => x.Name == "Joe").ToList(); //var allSalesByJoe2 = query1.Where(x => x.Name == "George").ToList(); //var filter1 = query1.Where(x => x.Value.Contains("t")).Select(x => x.Value); //var filter2 = query1.Where(x => x.Value.Contains("t")).Select(x => x.Value); //var result1 = filter1.ToList(); //var result2 = filter2.ToList(); //var t = filter1.FirstOrDefault(); }
private static CacheRepository InitializeSut() { var jsonSerializer = new JsonContractSerializer(); innerRepository = new FakeRepository(jsonSerializer); var memCache = new InMemoryCacheProvider(); var sut = new CacheRepository(innerRepository, memCache); return sut; }
ICacheManager GetCacheManager() { ICacheManager cm = null; var cp = new InMemoryCacheProvider(); cm = new CacheManager(cp); return(cm); }
public CustomWebSocketCommandInvocator(IConnectionManager connectionManager, IWebSocketConnector <CustomWebSocketCommandInvocator> webSocketConnector, InMemoryCacheProvider cacheProvider, ILogger <CustomWebSocketCommandInvocator> logger) { _connectionManager = connectionManager; _webSocketConnector = webSocketConnector; _cacheProvider = cacheProvider; _logger = logger; }
ICacheManager GetCacheManager() { bool runTestForRedisProvider = false; ICacheManager cm = null; if (runTestForRedisProvider) { //Make sure you have redis installed locally and have default port 6379. Or update following redisConfig value string redisConfig = "localhost:6379,defaultDatabase=1,allowAdmin=true"; var redisCp = new Redis.SeRedisCacheProvider(redisConfig); cm = new CacheManager(redisCp); } else { var cp = new InMemoryCacheProvider(); cm = new CacheManager(cp); } return(cm); }
public AnotherEndpointWebSocketCommandInvocator(IConnectionManager connectionManager, InMemoryCacheProvider cacheProvider, ILogger <CustomWebSocketCommandInvocator> logger) { _connectionManager = connectionManager; _cacheProvider = cacheProvider; _logger = logger; }
public CustomWebSocketCommandInvocator(IConnectionManager connectionManager, InMemoryCacheProvider cacheProvider) { _connectionManager = connectionManager; _cacheProvider = cacheProvider; }