Пример #1
1
        /// <summary>
        /// The constructor.
        /// </summary>
        /// <param name="cacheClient">The cache client.</param>
        public DacheMvcChildActionCache(ICacheClient cacheClient)
            : base("Dache MVC Child Action Cache")
        {
            // Sanitize
            if (cacheClient == null)
            {
                throw new ArgumentNullException("cacheClient");
            }

            _cacheClient = cacheClient;
        }
Пример #2
0
 public SessionPlugin(ICacheClient cacheClient, IEventRepository eventRepository, AssignToStackAction assignToStack, UpdateStatsAction updateStats, LocationPlugin locationPlugin, ILoggerFactory loggerFactory = null) : base(loggerFactory) {
     _cacheClient = new ScopedCacheClient(cacheClient, "session");
     _eventRepository = eventRepository;
     _assignToStack = assignToStack;
     _updateStats = updateStats;
     _locationPlugin = locationPlugin;
 }
 public SetLocationFromGeoWorkItemHandler(ICacheClient cacheClient, IEventRepository eventRepository, IGeocodeService geocodeService, IMetricsClient metricsClient, IMessageBus messageBus, ILoggerFactory loggerFactory = null) : base(loggerFactory) {
     _cacheClient = new ScopedCacheClient(cacheClient, "geo");
     _eventRepository = eventRepository;
     _geocodeService = geocodeService;
     _metricsClient = metricsClient;
     _lockProvider = new CacheLockProvider(cacheClient, messageBus);
 }
Пример #4
0
 public StatsController(ErrorStatsHelper statsHelper, IOrganizationRepository organizationRepository, IErrorStackRepository errorStackRepository, IProjectRepository projectRepository, ICacheClient cacheClient) {
     _cacheClient = cacheClient;
     _statsHelper = statsHelper;
     _organizationRepository = organizationRepository;
     _errorStackRepository = errorStackRepository;
     _projectRepository = projectRepository;
 }
 public ThrottleBotsPlugin(ICacheClient cacheClient, IEventRepository eventRepository, IProjectRepository projectRepository, IMetricsClient metricsClient, IQueue<WorkItemData> workItemQueue) {
     _cacheClient = cacheClient;
     _metricsClient = metricsClient;
     _eventRepository = eventRepository;
     _projectRepository = projectRepository;
     _workItemQueue = workItemQueue;
 }
Пример #6
0
 public AccountController(IDbConnection db, IMetricTracker metrics, ICacheClient cache, IMailController mailController, IUserService userService, IUserAuthenticationService authenticationService)
     : base(db, metrics, cache)
 {
     _mailController = mailController;
     _userService = userService;
     _authenticationService = authenticationService;
 }
 public SystemHealthChecker(ICacheClient cacheClient, IElasticClient elasticClient, IFileStorage storage, IQueue<StatusMessage> queue, IMessageBus messageBus) {
     _cacheClient = cacheClient;
     _elasticClient = elasticClient;
     _storage = storage;
     _queue = queue;
     _messageBus = messageBus;
 }
Пример #8
0
 public ThrottlingHandler(ICacheClient cacheClient, IMetricsClient metricsClient, Func<string, long> maxRequestsForUserIdentifier, TimeSpan period, string message = "The allowed number of requests has been exceeded.") {
     _cacheClient = cacheClient;
     _metricsClient = metricsClient;
     _maxRequestsForUserIdentifier = maxRequestsForUserIdentifier;
     _period = period;
     _message = message;
 }
 public AutoSessionPlugin(ICacheClient cacheClient, IEventRepository eventRepository, AssignToStackAction assignToStack, UpdateStatsAction updateStats, LocationPlugin locationPlugin) {
     _cacheClient = new ScopedCacheClient(cacheClient, "session");
     _eventRepository = eventRepository;
     _assignToStack = assignToStack;
     _updateStats = updateStats;
     _locationPlugin = locationPlugin;
 }
 public void OnBeforeEachTest()
 {
     cacheClient = new MemoryCacheClient();
     //cacheClient = new RedisCacheClient(TestConfig.SingleHost);
     cacheClient.FlushAll();
     model = ModelWithIdAndName.Create(1);
     xmlModel = DataContractSerializer.Instance.Parse(model);
 }
        public virtual void OneTimeSetUp()
        {
            var serializer = GetSerializer();

            // Configured via app.config
            var conn = RedisConnectionManager.Instance.GetDefaultConnection();
            _client = new StackExchangeRedisCacheClient(conn, serializer);
        }
 public MyAppElasticConfiguration(IQueue<WorkItemData> workItemQueue, ICacheClient cacheClient, IMessageBus messageBus, ILoggerFactory loggerFactory) : base(workItemQueue, cacheClient, messageBus, loggerFactory) {
     AddIndex(Identities = new IdentityIndex(this));
     AddIndex(Employees = new EmployeeIndex(this));
     AddIndex(MonthlyEmployees = new MonthlyEmployeeIndex(this, 1));
     AddIndex(DailyLogEvents = new DailyLogEventIndex(this));
     AddIndex(MonthlyLogEvents = new MonthlyLogEventIndex(this));
     AddIndex(ParentChild = new ParentChildIndex(this));
 }
Пример #13
0
 protected BaseController(IDbConnection db, IMetricTracker metrics, ICacheClient cache)
 {
     Db = db;
     Metrics = metrics;
     Log = LogManager.GetLogger(GetType());
     Cache = cache;
     CacheContext = new CacheContext(Cache);
 }
		public void OnBeforeEachTest()
		{
			if (cacheClient != null)
				cacheClient.Dispose();

			cacheClient = new RedisClient(TestConfig.SingleHost);
			cacheClient.FlushAll();
		}
 public RemoveProjectWorkItemHandler(IProjectRepository projectRepository, IEventRepository eventRepository, IStackRepository stackRepository, ITokenRepository tokenRepository, IWebHookRepository webHookRepository, ICacheClient cacheClient, IMessageBus messageBus, ILoggerFactory loggerFactory = null) : base(loggerFactory) {
     _projectRepository = projectRepository;
     _eventRepository = eventRepository;
     _stackRepository = stackRepository;
     _tokenRepository = tokenRepository;
     _webHookRepository = webHookRepository;
     _lockProvider = new CacheLockProvider(cacheClient, messageBus);
 }
        public CacheBucketMetricsClientBase(ICacheClient cache, bool buffered = true, string prefix = null, ILoggerFactory loggerFactory = null) {
            _logger = loggerFactory.CreateLogger(GetType());
            _cache = cache;
            _buffered = buffered;
            _prefix = !String.IsNullOrEmpty(prefix) ? (!prefix.EndsWith(":") ? prefix + ":" : prefix) : String.Empty;

            if (buffered)
                _flushTimer = new Timer(OnMetricsTimer, null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2));
        }
Пример #17
0
 public DailySummaryJob(IProjectRepository projectRepository, IOrganizationRepository organizationRepository, IUserRepository userRepository, IEventRepository eventRepository, EventStats stats, IMailer mailer, ICacheClient cacheClient, ILoggerFactory loggerFactory = null) : base(loggerFactory) {
     _projectRepository = projectRepository;
     _organizationRepository = organizationRepository;
     _userRepository = userRepository;
     _eventRepository = eventRepository;
     _stats = stats;
     _mailer = mailer;
     _lockProvider = new ThrottlingLockProvider(cacheClient, 1, TimeSpan.FromHours(1));
 }
Пример #18
0
        public ThrottlingLockProvider(ICacheClient cacheClient, int maxHitsPerPeriod = 100, TimeSpan? throttlingPeriod = null) {
            _cacheClient = cacheClient;
            _maxHitsPerPeriod = maxHitsPerPeriod;

            if (maxHitsPerPeriod <= 0)
                throw new ArgumentException("Must be a positive number.", nameof(maxHitsPerPeriod));
            
            if (throttlingPeriod.HasValue)
                _throttlingPeriod = throttlingPeriod.Value;
        }
Пример #19
0
        public ThrottlingLockProvider(ICacheClient cacheClient, int maxHitsPerPeriod = 100, TimeSpan? throttlingPeriod = null, ILoggerFactory loggerFactory = null) {
            _logger = loggerFactory.CreateLogger<ThrottlingLockProvider>();
            _cacheClient = new ScopedCacheClient(cacheClient, "lock:throttled");
            _maxHitsPerPeriod = maxHitsPerPeriod;

            if (maxHitsPerPeriod <= 0)
                throw new ArgumentException("Must be a positive number.", nameof(maxHitsPerPeriod));
            
            if (throttlingPeriod.HasValue)
                _throttlingPeriod = throttlingPeriod.Value;
        }
Пример #20
0
        public CachedEventService(TimeSpan? ttl, ICacheClient client, ICacheKeyBuilder<Guid> keyBuilder, ILogFactory factory)
        {
            if (client == null) throw new ArgumentNullException("client");
            if (keyBuilder == null) throw new ArgumentNullException("keyBuilder");
            if (factory == null) throw new ArgumentNullException("factory");

            this.ttl = ttl;
            this.client = client;
            this.factory = factory;
            this.keyBuilder = keyBuilder;
        }
Пример #21
0
 public StatusController(ICacheClient cacheClient, IMessagePublisher messagePublisher, SystemHealthChecker healthChecker, IQueue<EventPost> eventQueue, IQueue<MailMessage> mailQueue, IQueue<EventNotificationWorkItem> notificationQueue, IQueue<WebHookNotification> webHooksQueue, IQueue<EventUserDescription> userDescriptionQueue, IMetricsClient metricsClient) {
     _cacheClient = cacheClient;
     _messagePublisher = messagePublisher;
     _healthChecker = healthChecker;
     _eventQueue = eventQueue;
     _mailQueue = mailQueue;
     _notificationQueue = notificationQueue;
     _webHooksQueue = webHooksQueue;
     _userDescriptionQueue = userDescriptionQueue;
     _metricsClient = metricsClient;
 }
Пример #22
0
        public MigrationJobBase(IElasticClient elasticClient, EventUpgraderPluginManager eventUpgraderPluginManager, EventIndex eventIndex, StackIndex stackIndex, IValidator<Stack> stackValidator, IValidator<PersistentEvent> eventValidator, IGeoIPResolver geoIpResolver, ILockProvider lockProvider, ICacheClient cache) {
            _eventUpgraderPluginManager = eventUpgraderPluginManager;
            _mongoDatabase = GetMongoDatabase();
            _eventRepository = new EventMigrationRepository(elasticClient, eventIndex, eventValidator);
            _stackRepository = new StackMigrationRepository(elasticClient, stackIndex, _eventRepository, stackValidator);
            _geoIpResolver = geoIpResolver;
            _lockProvider = lockProvider;
            _cache = cache;

            _batchSize = MigrationSettings.Current.MigrationBatchSize;
        }
 public EventNotificationsJob(IQueue<EventNotificationWorkItem> queue, IMailer mailer,
     IOrganizationRepository organizationRepository, IProjectRepository projectRepository, IStackRepository stackRepository,
     IUserRepository userRepository, IEventRepository eventRepository, ICacheClient cacheClient) {
     _queue = queue;
     _mailer = mailer;
     _organizationRepository = organizationRepository;
     _projectRepository = projectRepository;
     _stackRepository = stackRepository;
     _userRepository = userRepository;
     _eventRepository = eventRepository;
     _cacheClient = cacheClient;
 }
		protected CacheClientTestBase(ISerializer serializer)
		{
			Serializer = serializer;
		    var mux = ConnectionMultiplexer.Connect(new ConfigurationOptions
		    {
		        DefaultVersion = new Version(3, 0, 500),
		        EndPoints = {{"localhost", 6379}},
		        AllowAdmin = true
		    });

            Sut = new StackExchangeRedisCacheClient(mux, Serializer);
			Db = Sut.Database;
		}
        public void SetupTests()
        {

            _client = new DynamoDbCacheClient(yourAwsAccountKey, yourAwsSecretKey,
                                              RegionEndpoint.USEast1, "ICacheClientDynamoDb", 10, 5, true);
            // The primary item we'll be caching in the tests.
            _item = new DummyObject
                        {
                            UserId = "john.doe",
                            Email = "[email protected]",
                            Phone = "555-555-9876",
                            Friends = new List<string> {"jane.doe", "jack.doe", "some.friend"}
                        };            
        }
Пример #26
0
        public static void CacheAllWorlds(this IDbConnection db, ICacheClient cache)
        {
            cache.FlushAll();

            // concurrently create a list of world ids
            var worlds = db.GetWorlds();

            Parallel.ForEach<World>(worlds, w =>
            {
                var cacheKey = UrnId.Create<World>("Id", w.id.ToString());

                cache.Set<World>(cacheKey, w);
            });
        }
Пример #27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BoardsService"/> class.
        /// </summary>
        /// <param name="boardsRepository">
        /// The boards repository.
        /// </param>
        /// <param name="cacheClient">
        /// The cache Client.
        /// </param>
        public BoardsService(IBoardsRepository boardsRepository, ICacheClient cacheClient)
        {
            if (boardsRepository == null)
            {
                throw new ArgumentNullException("boardsRepository", "Boards repository is required.");
            }

            if (cacheClient == null)
            {
                throw new ArgumentNullException("cacheClient", "Cache client is required.");
            }

            this.boardsRepository = boardsRepository;
            this.cacheClient = cacheClient;
        }
 public CityDetailsPageViewModel(IClock clock, IDataRepository repository, 
     IEventAggregator eventAggregator, 
     INavigationService navigationService,
     ICacheClient cacheClient)
 {
     _clock = clock;
     _repository = repository;
     _eventAggregator = eventAggregator;
     _navigationService = navigationService;
     _cacheClient = cacheClient;
     var clocks = _repository.GetUsersCities();
     Clocks = new ObservableCollection<CityInfo>(clocks);
     ApplySelection = new DelegateCommand<SelectionChangedEventArgs>(ApplySelectionInternal);
     Delete = new RelayCommand(HandleDelete);
 }
Пример #29
0
        /// <summary>
        /// Static constructor.
        /// </summary>
        static DacheOutputCacheProvider()
        {
            // Use the user provided settings
            var cacheClientConfig = CacheClientConfigurationSection.Settings;

            if (cacheClientConfig == null) throw new InvalidOperationException("You cannot use the Dache output cache provider without supplying Dache configuration in your web or app config file");

            // TODO: the below sucks. Improve it.

            // Clone to protect from mutated state
            var cacheClientConfigClone = (CacheClientConfigurationSection)cacheClientConfig.Clone();
            // Use binary serializer
            cacheClientConfigClone.CustomSerializer.Type = typeof(BinarySerializer).AssemblyQualifiedName;
            // Use Debug logger
            cacheClientConfigClone.CustomLogger.Type = typeof(DebugLogger).AssemblyQualifiedName;
            _cacheClient = new CacheClient(cacheClientConfigClone);
        }
        protected static void AssertCacheClientMissingModelValuesAsKeysWithNullValues(
			ICacheClient cacheClient)
        {
            var allKeys = new[] { "test:modelkey1", "test:modelkey2", "test:modelkey3" };
            var expectedValues = new[] { ModelWithIdAndName.Create(1), null, ModelWithIdAndName.Create(1) };
            cacheClient.Set(allKeys[0], expectedValues[0]);
            cacheClient.Set(allKeys[2], expectedValues[2]);

            var keyValues = cacheClient.GetAll<ModelWithIdAndName>(allKeys);
            Assert.That(keyValues, Has.Count.EqualTo(expectedValues.Length));

            for (var keyIndex = 0; keyIndex < expectedValues.Length; keyIndex++)
            {
                var key = allKeys[keyIndex];
                var keyValue = keyValues[key];

                ModelWithIdAndName.AssertIsEqual(keyValue, expectedValues[keyIndex]);
            }
        }