コード例 #1
0
        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 }));
        }
コード例 #2
0
        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();
        }
コード例 #3
0
 private static CacheRepository InitializeSut()
 {
     var jsonSerializer = new JsonContractSerializer();
     innerRepository = new FakeRepository(jsonSerializer);
     var memCache = new InMemoryCacheProvider();
     var sut = new CacheRepository(innerRepository, memCache);
     return sut;
 }
コード例 #4
0
        ICacheManager GetCacheManager()
        {
            ICacheManager cm = null;
            var           cp = new InMemoryCacheProvider();

            cm = new CacheManager(cp);
            return(cm);
        }
コード例 #5
0
 public CustomWebSocketCommandInvocator(IConnectionManager connectionManager,
                                        IWebSocketConnector <CustomWebSocketCommandInvocator> webSocketConnector,
                                        InMemoryCacheProvider cacheProvider,
                                        ILogger <CustomWebSocketCommandInvocator> logger)
 {
     _connectionManager  = connectionManager;
     _webSocketConnector = webSocketConnector;
     _cacheProvider      = cacheProvider;
     _logger             = logger;
 }
コード例 #6
0
        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);
        }
コード例 #7
0
 public AnotherEndpointWebSocketCommandInvocator(IConnectionManager connectionManager, InMemoryCacheProvider cacheProvider, ILogger <CustomWebSocketCommandInvocator> logger)
 {
     _connectionManager = connectionManager;
     _cacheProvider     = cacheProvider;
     _logger            = logger;
 }
コード例 #8
0
 public CustomWebSocketCommandInvocator(IConnectionManager connectionManager,
                                        InMemoryCacheProvider cacheProvider)
 {
     _connectionManager = connectionManager;
     _cacheProvider     = cacheProvider;
 }