/// <summary> /// The constructor. /// </summary> /// <param name="cacheHostInformationPoller">The cache host information poller.</param> /// <param name="memCache">The mem cache to use for storing objects.</param> /// <param name="clientToCacheServiceHost">The client to cache service host.</param> /// <param name="cacheManagerClient">The cache manager client.</param> public CacheHostEngine(IRunnable cacheHostInformationPoller, IMemCache memCache, ServiceHost clientToCacheServiceHost) { // Sanitize if (cacheHostInformationPoller == null) { throw new ArgumentNullException("cacheHostInformationPoller"); } if (memCache == null) { throw new ArgumentNullException("memCache"); } if (clientToCacheServiceHost == null) { throw new ArgumentNullException("clientToCacheServiceHost"); } // Set the cache host information poller _cacheHostInformationPoller = cacheHostInformationPoller; // Set the mem cache container instance MemCacheContainer.Instance = memCache; // Initialize the service hosts _clientToCacheServiceHost = clientToCacheServiceHost; }
/// <summary> /// The constructor. /// </summary> /// <param name="memCache">The mem cache.</param> /// <param name="tagRoutingTable">The tag routing table.</param> /// <param name="logger">The logger.</param> /// <param name="port">The port.</param> /// <param name="maximumConnections">The maximum number of simultaneous connections.</param> /// <param name="messageBufferSize">The buffer size to use for sending and receiving data.</param> /// <param name="timeoutMilliseconds">The communication timeout, in milliseconds.</param> /// <param name="maxMessageSize">The maximum message size, in bytes.</param> public CacheHostServer(IMemCache memCache, ITagRoutingTable tagRoutingTable, ILogger logger, int port, int maximumConnections, int messageBufferSize, int timeoutMilliseconds, int maxMessageSize) { // Sanitize if (memCache == null) { throw new ArgumentNullException("memCache"); } if (tagRoutingTable == null) { throw new ArgumentNullException("tagRoutingTable"); } if (logger == null) { throw new ArgumentNullException("logger"); } // Set the default cache item policies _defaultCacheItemPolicy = new CacheItemPolicy(); _defaultRemovedCallbackCacheItemPolicy = new CacheItemPolicy { RemovedCallback = CacheItemRemoved }; // Set the mem cache _memCache = memCache; // Set the tag routing table _tagRoutingTable = tagRoutingTable; // Set the logger _logger = logger; // Set maximum connections and message buffer size _maximumConnections = maximumConnections; _messageBufferSize = messageBufferSize; // Establish the endpoint for the socket var ipHostInfo = Dns.GetHostEntry(string.Empty); // Listen on all interfaces _localEndPoint = new IPEndPoint(IPAddress.Any, port); // Define the server _server = new SimplSocketServer(() => new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp), messageBufferSize: messageBufferSize, communicationTimeout: timeoutMilliseconds, maxMessageSize: maxMessageSize, maximumConnections: maximumConnections); // Hook into events _server.ClientConnected += (sender, e) => { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("CONN: Dache Client Connected"); Console.ForegroundColor = ConsoleColor.Cyan; }; _server.MessageReceived += ReceiveMessage; _server.Error += (sender, e) => { _logger.Warn("Dache Client Disconnected", e.Exception); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("WARN: Dache Client Disconnected"); Console.WriteLine("WARN: Reason = " + e.Exception.Message); Console.ForegroundColor = ConsoleColor.Cyan; }; }
/// <summary> /// The constructor. /// </summary> /// <param name="memCache">The mem cache.</param> /// <param name="tagRoutingTable">The tag routing table.</param> /// <param name="port">The port.</param> /// <param name="maximumConnections">The maximum number of simultaneous connections.</param> /// <param name="messageBufferSize">The buffer size to use for sending and receiving data.</param> public CacheHostServer(IMemCache memCache, ITagRoutingTable tagRoutingTable, int port, int maximumConnections, int messageBufferSize) { // Sanitize if (memCache == null) { throw new ArgumentNullException("memCache"); } if (tagRoutingTable == null) { throw new ArgumentNullException("tagRoutingTable"); } if (port <= 0) { throw new ArgumentException("cannot be <= 0", "port"); } if (maximumConnections <= 0) { throw new ArgumentException("cannot be <= 0", "maximumConnections"); } if (messageBufferSize < 256) { throw new ArgumentException("cannot be < 256", "messageBufferSize"); } // Set the mem cache _memCache = memCache; // Set the tag routing table _tagRoutingTable = tagRoutingTable; // Set maximum connections and message buffer size _maximumConnections = maximumConnections; _messageBufferSize = messageBufferSize; // Establish the endpoint for the socket var ipHostInfo = Dns.GetHostEntry(string.Empty); // Listen on all interfaces _localEndPoint = new IPEndPoint(IPAddress.Any, port); // Define the server _server = SimplSocket.CreateServer(() => new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp), (sender, e) => { /* Ignore it, client's toast */ }, ReceiveMessage, messageBufferSize, maximumConnections, false); // Load custom logging _logger = CustomLoggerLoader.LoadLogger(); }
public PointsDatabase(IMemCache memCache, IList<MapPoint> points) { _memCache = memCache; Points = _memCache.Get<IList<MapPoint>>(CacheKeys.PointsDatabase); if (Points != null) return; // cache hit lock (_threadsafe) { //Points = _memCache.Get<IList<MapPoint>>(CacheKeys.PointsDatabase); //if (Points != null) return; Points = new List<MapPoint>(); // Not important, can be deleted, only for ensuring visual randomness of marker display // when not all can be displayed on screen // // Randomize order, when limit take is used for max marker display // random locations are selected // http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle var rnd = new Random(); var count = points.Count; for (var i = 0; i < count; i++) { MapPoint tmp = points[i]; int r = rnd.Next(count); points[i] = points[r]; points[r] = tmp; } Points = points; _memCache.Set<IList<MapPoint>>(CacheKeys.PointsDatabase, Points, TimeSpan.FromHours(24)); var data = _memCache.Get<IList<MapPoint>>(CacheKeys.PointsDatabase); if (data == null) { throw new Exception("cache not working"); } } }
/// <summary> /// The constructor. /// </summary> /// <param name="memCache">The mem cache.</param> /// <param name="customPerformanceCounterManager">The custom performance counter manager.</param> /// <param name="pollingIntervalMilliseconds">The polling interval, in milliseconds.</param> public CacheHostInformationPoller(IMemCache memCache, ICustomPerformanceCounterManager customPerformanceCounterManager, int pollingIntervalMilliseconds) { // Sanitize if (memCache == null) { throw new ArgumentNullException("memCache"); } if (customPerformanceCounterManager == null) { throw new ArgumentNullException("customPerformanceCounterManager"); } if (pollingIntervalMilliseconds <= 0) { throw new ArgumentException("Interval must be > 0", "pollingIntervalMilliseconds"); } _memCache = memCache; _customPerformanceCounterManager = customPerformanceCounterManager; _pollingIntervalMilliseconds = pollingIntervalMilliseconds; // Initialize the cache host information polling timer _cacheHostInformationPollingTimer = new Timer(PollCacheHost, null, Timeout.Infinite, Timeout.Infinite); }
public SampleController(ISampleService sampleService, IMemCache <Sample> memCache) { _sampleService = sampleService; _memCache = memCache; _key = "sample"; }
public PointsDatabase(IMemCache memCache, string filepath) { _memCache = memCache; Points = _memCache.Get <IList <P> >(CacheKeys.PointsDatabase); if (Points != null) { return; // cache hit } lock (_threadsafe) { Points = _memCache.Get <IList <P> >(CacheKeys.PointsDatabase); if (Points != null) { return; } var sw = new Stopwatch(); sw.Start(); Points = new List <P>(); FilePath = filepath; // Load from file List <P> points = Utility.Dataset.LoadDataset(FilePath); if (points.None()) { throw new Exception(string.Format("Data was not loaded from file: {0}", FilePath)); } if (points.Count > GmcSettings.Get.MaxPointsInCache) { points = points.Take(GmcSettings.Get.MaxPointsInCache).ToList(); } // Not important, can be deleted, only for ensuring visual randomness of marker display // when not all can be displayed on screen // // Randomize order, when limit take is used for max marker display // random locations are selected // http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle var rand = new Random(); var c = points.Count; for (var i = 0; i < c; i++) { P temp = points[i]; int r = rand.Next(c); points[i] = points[r]; points[r] = temp; } var linkedList = new LinkedList <P>(); points.ForEach(p => linkedList.AddLast(p)); Points = points; _memCache.Set <IList <P> >(Points, CacheKeys.PointsDatabase, TimeSpan.FromHours(24)); var data = _memCache.Get <IList <P> >(CacheKeys.PointsDatabase); if (data == null) { throw new Exception("cache not working"); } sw.Stop(); LoadTime = sw.Elapsed; } }
public AddHandler(RequestConverters helpers, IMemCache cache) : base(helpers, cache) { }
public static Dictionary <string, IRequestHandler> GetRequestHandlers(IScheduler scheduler, IMemCache cache) { var helpers = new RequestConverters(scheduler); var getHandler = new GetHandler(helpers, cache, scheduler); var mutateHandler = new MutateHandler(helpers, cache, scheduler); return(new Dictionary <string, IRequestHandler> { { "get", getHandler }, { "gets", getHandler }, { "set", new SetHandler(helpers, cache) }, { "append", new AppendHandler(helpers, cache) }, { "prepend", new PrependHandler(helpers, cache) }, { "add", new AddHandler(helpers, cache) }, { "replace", new ReplaceHandler(helpers, cache) }, { "cas", new CasHandler(helpers, cache) }, { "stats", new StatsHandler() }, { "delete", new DeleteHandler(helpers, cache) }, { "flush_all", new FlushHandler(cache, scheduler) }, { "quit", new QuitHandler() }, { "exception", new ExceptionHandler() }, { "version", new VersionHandler() }, { "touch", new TouchHandler(helpers, cache) }, { "incr", mutateHandler }, { "decr", mutateHandler }, }); }
public ClusterService(IPointCollection pointCollection) { _pointCollection = pointCollection; _memCache = new MemCache(); }
public QueryAllCachedRepository(TContext dbContext, IUnitOfWork unitOfWork, IMemCache cache) : base(dbContext, unitOfWork) { _cache = cache; }
public RandomEvictionStrategy(IMemCache cache) { _cache = cache; }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public OperationAuth(IMemCache pMemCache, Func <IDataAccess> pGetDataAcc, Func <long> pGetUtcNow) { vMemCache = pMemCache; vGetDataAcc = pGetDataAcc; vGetUtcNow = pGetUtcNow; }
public ConsultantController(IConsultantService consultantService, IMemCache cache, ILog <ConsultantController> logger, IMapper mapper) : base(logger) { _consultantService = consultantService; _mapper = mapper; }
public CasHandler(RequestConverters helpers, IMemCache cache) { _helpers = helpers; _cache = cache; }
public MapService(IPointsDatabase pointsDatabase, IMemCache memCache) { _pointsDatabase = pointsDatabase; _memCache = memCache; }
public void Setup() { IWindsorContainer container = new Castle.Windsor.WindsorContainer(); container.Install(new MemcacheInstaller("Dache_Test",false)); _memCache = container.Resolve<IMemCache>(new { cacheName = TestName, cacheConfig = Config }); }
public FlushHandler(IMemCache cache, IScheduler scheduler) { _cache = cache; _scheduler = scheduler; }
public PointCollection() { _memCache = new MemCache(); }
public CacheEntrySubscriptionHandler(IMemCache cache, IObserver <string> responseObserver) // Not sure how right it { _cache = cache; _responseObserver = responseObserver; }
public TouchHandler(RequestConverters converters, IMemCache cache) { _converters = converters; _cache = cache; }
public PointsDatabase(IMemCache memCache, string filepath) { _memCache = memCache; Points = _memCache.Get<IList<P>>(CacheKeys.PointsDatabase); if (Points != null) return; // cache hit lock (_threadsafe) { Points = _memCache.Get<IList<P>>(CacheKeys.PointsDatabase); if (Points != null) return; var sw = new Stopwatch(); sw.Start(); Points = new List<P>(); FilePath = filepath; // Load from file List<P> points = Utility.Dataset.LoadDataset(FilePath); if (points.None()) { throw new Exception(string.Format("Data was not loaded from file: {0}", FilePath)); } if (points.Count > GmcSettings.Get.MaxPointsInCache) { points = points.Take(GmcSettings.Get.MaxPointsInCache).ToList(); } // Not important, can be deleted, only for ensuring visual randomness of marker display // when not all can be displayed on screen // // Randomize order, when limit take is used for max marker display // random locations are selected // http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle var rand = new Random(); var c = points.Count; for (var i = 0; i < c; i++) { P temp = points[i]; int r = rand.Next(c); points[i] = points[r]; points[r] = temp; } var linkedList = new LinkedList<P>(); points.ForEach(p => linkedList.AddLast(p)); Points = points; _memCache.Set<IList<P>>(Points, CacheKeys.PointsDatabase, TimeSpan.FromHours(24)); var data = _memCache.Get<IList<P>>(CacheKeys.PointsDatabase); if (data == null) { throw new Exception("cache not working"); } sw.Stop(); LoadTime = sw.Elapsed; } }
public MutateHandler(RequestConverters helpers, IMemCache cache, IScheduler scheduler) { _helpers = helpers; _cache = cache; }
public CacheRestorer(IMemCache memCache, IFileSystem fileSystem, string path) : this(memCache, fileSystem, path, Scheduler.Default) { }
public RequestDispatcher(IScheduler scheduler, IMemCache cache, Dictionary <string, IRequestHandler> requestHandlers) { _requestHandlers = requestHandlers; }
/// <summary> /// Initializes a new instance of the <see cref="GZipMemCache"/> class. /// </summary> /// <param name="memCache">The memory cache.</param> public GZipMemCache(IMemCache memCache) { _memCache = memCache; }
public GetHandler(RequestConverters helpers, IMemCache cache, IScheduler scheduler) { _helpers = helpers; _cache = cache; _scheduler = scheduler; }
public MangaIndex(IMangaDownloader manager, IMetaDataRepository metaDataService, IMemCache memCache) { _manager = manager; _metaDataService = metaDataService; _memCache = memCache; MyDictionary = CreateDictionary(); //todo }
private string Add(IMemCache cache) { var itemPolicy = new CacheItemPolicy(); var key = Guid.NewGuid().ToString(); cache.Add(key, new byte[100], itemPolicy); return key; }
public ConfigsController(IMemCache cache, ILog <ConfigsController> logger, IMapper mapper) { this._cache = cache; this._mapper = mapper; }