public SeoRouteValueDictionary(string siteMapNodeKey, string memberName, ISiteMap siteMap,
     IReservedAttributeNameProvider reservedAttributeNameProvider,
     IJsonToDictionaryDeserializer jsonToDictionaryDeserializer, ICache cache)
     : base(
         siteMapNodeKey, memberName, siteMap, reservedAttributeNameProvider, jsonToDictionaryDeserializer, cache)
 {
 }
Example #2
0
        /// <summary>
        /// Prints the cache entries.
        /// </summary>
        /// <param name="cache">The cache.</param>
        private static void PrintCacheEntries(ICache<int, int> cache)
        {
            Console.WriteLine("\n>>> Entries in cache:");

            foreach (var entry in cache)
                Console.WriteLine(entry);
        }
 public RandomDayDateTimeProvider(ICache cache, IDictionary<string, string> settings)
 {
     this.settings = settings;
     start = Convert.ToDateTime(settings[Keys.DateTimeMinValue]);
     end = Convert.ToDateTime(settings[Keys.DateTimeMaxValue]);
     range = (end - start).Days;
 }
        protected Element(MSpecUnitTestProvider provider,
                          IPsi psiModuleManager,
                          ICache cacheManager,
                          Element parent,
                          ProjectModelElementEnvoy projectEnvoy,
                          IClrTypeName declaringTypeName,
                          bool isIgnored)
        {
            if (declaringTypeName == null)
            {
                throw new ArgumentNullException("declaringTypeName");
            }

            if (projectEnvoy != null)
            {
                this._projectEnvoy = projectEnvoy;
            }

            this._provider = provider;
            this._declaringTypeName = declaringTypeName;
            this._psiModuleManager = psiModuleManager;
            this._cacheManager = cacheManager;

            if (isIgnored)
            {
                this.ExplicitReason = "Ignored";
            }

            this.TypeName = declaringTypeName;
            this.Parent = parent;

            this.Children = new List<IUnitTestElement>();
            this.State = UnitTestElementState.Valid;
            this._taskFactory = new UnitTestTaskFactory(this._provider.ID);
        }
Example #5
0
 public Chat(IResourceProcessor resourceProcessor, IChatService service, IJabbrRepository repository, ICache cache)
 {
     _resourceProcessor = resourceProcessor;
     _service = service;
     _repository = repository;
     _cache = cache;
 }
		public UpdateTimestampsCache(Settings settings, IDictionary props)
		{
			string prefix = settings.CacheRegionPrefix;
			regionName = prefix == null ? regionName : prefix + '.' + regionName;
			log.Info("starting update timestamps cache at region: " + regionName);
			this.updateTimestamps = settings.CacheProvider.BuildCache(regionName, props);
		}
Example #7
0
        public LinkGenerator(IPersister persister, ConnectionMonitor connection, CacheWrapper cacheWrapper, IRequestLogger logger)
        {
            _logger = logger;

            // DON'T USE DISTRIBUTED CACHE FOR N2 internal data 
            // _urlCache = cacheService.GetCache<string>(new CacheConfig("LinkGenerator_urlCache", 1800));
            _urlCache = new HttpRuntimeCacheWrapper<string>("LinkGenerator_urlCache", cacheWrapper);
            _itemCache = new HttpRuntimeCacheWrapper<object>("LinkGenerator_urlCache_item", cacheWrapper);

            // hook up to persister events
            connection.Online += delegate
            {
                persister.ItemSaved += persister_ItemSaved;
                persister.ItemMoving += persister_ItemMoving;
                persister.ItemMoved += persister_ItemMoved;
                persister.ItemCopied += persister_ItemCopied;
                persister.ItemDeleted += persister_ItemDeleted;
                persister.FlushCache += persister_ItemInvalidated;
            };
            connection.Offline += delegate
            {
                persister.ItemSaved -= persister_ItemSaved;
                persister.ItemMoving -= persister_ItemMoving;
                persister.ItemMoved -= persister_ItemMoved;
                persister.ItemCopied -= persister_ItemCopied;
                persister.ItemDeleted -= persister_ItemDeleted;
                persister.FlushCache -= persister_ItemInvalidated;
            };
        }
Example #8
0
        public ISession CreateSession(IDictionary<string, string> parameters, IObjectFactory objectFactory, AbstractAuthenticationProvider authenticationProvider, ICache cache)
        {
            Session session = new Session(parameters, objectFactory, authenticationProvider, cache);
            session.Connect();

            return session;
        }
 public DataTableHandler(DataSet dataSet)
 {
     _cache = new SimpleCache();
     _precache = new Hashtable();
     _dset = dataSet;
     _hasRelations = false;
 }
Example #10
0
 public SplashViewModel(INavigationService navigationService, ITrelloApiSettings settings, ITrello api, ICache cache)
 {
     _navigationService = navigationService;
     _settings = settings;
     _cache = cache;
     _api = api;
 }
 static ServerCoreManager()
 {
     UpdateLock = new object();
     ServerCores = new Dictionary<string, ServerCore>();
     QueryCache = Configuration.QueryCache;
     PersistenceType = Configuration.PersistenceType;
 }
Example #12
0
        ICache ICachingFactory.Create()
        {
            if (_caches == null)
            {
                lock (_syncObj)
                {
                    if (_caches == null)
                    {
                        var assemblyName = CachingConfig.GetCacheProvider();
                        if (String.IsNullOrWhiteSpace(assemblyName))
                        {
                            _caches = new NoCacheProvider();
                        }
                        else
                        {
                            var assemblys = assemblyName.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                            var handler = Activator.CreateInstance(assemblys[0], assemblys[1]);
                            var obj = handler.Unwrap();
                            _caches = obj as ICache;
                        }

                    }
                }
            }

            return _caches;
        }
        public OpenDatabaseViewModel(
            INavigationService navigationService,
            IDatabaseInfoRepository databaseInfoRepository,
            ICanSHA256Hash hasher,
            IDialogService dialogService,
            IPWDatabaseDataSource databaseSource,
            ICache cache)
        {
            _cache = cache;
            _databaseSource = databaseSource;
            _dialogService = dialogService;
            _databaseInfoRepository = databaseInfoRepository;
            _hasher = hasher;
            _navigationService = navigationService;
            var canHitOpen = this.WhenAny(
                vm => vm.Password, 
                vm => vm.KeyFileName,
                (p, k) => !string.IsNullOrEmpty(p.Value) || !string.IsNullOrEmpty(k.Value));

            OpenCommand = new ReactiveCommand(canHitOpen);
            OpenCommand.Subscribe(OpenDatabase);

            GetKeyFileCommand = new ReactiveCommand();
            GetKeyFileCommand.Subscribe(GetKeyFile); 
            
            ClearKeyFileCommand = new ReactiveCommand();
            ClearKeyFileCommand.Subscribe(ClearKeyFile);

            IObservable<string> keyFileNameChanged = this.WhenAny(vm => vm.KeyFileName, kf => kf.Value);
            keyFileNameChanged.Subscribe(v => ClearKeyFileButtonIsVisible = !string.IsNullOrWhiteSpace(v));
            keyFileNameChanged.Subscribe(v => GetKeyFileButtonIsVisible = string.IsNullOrWhiteSpace(v));
        }
Example #14
0
 /// <summary>
 /// Initializes a new instance of the Downloader class.
 /// </summary>
 /// <param name="maxConcurrentDownloads">The maximum number of concurrent downloads allowed.</param>
 /// <param name="cacheProfile">The <see cref="CacheProfile"/> to use.</param>
 public Downloader(int maxConcurrentDownloads, CacheProfile cacheProfile)
 {
     this.MaxConcurrentDownloads = maxConcurrentDownloads < 0 ? 0 : maxConcurrentDownloads;
     this.cache = Downloader.CreateCache(cacheProfile);
     this.processing = new List<DownloadTask>();
     this.queued = new List<DownloadTask>();
 }
 public BenchmarkRunner(ICache cache, IBenchmark benchmark)
 {
     _cache = cache;
     _benchmark = benchmark;
     _singleMeasurer = new SingleThreadedBenchmarkMeasurer(cache, benchmark);
     _multiMeasurer = new MultiThreadedBenchmarkMeasurer(cache, benchmark);
 }
Example #16
0
        public static void PreStartInitialise()
        {
            switch (WebConfigSettings.CacheProviderType)
            {

            #if !NET35
                case CacheTypes.AppFabricCache:

                    _cache = new AppFabricCacheAdapter();

                    break;

            #endif
                case CacheTypes.MemoryCache:
                default:
                    _cache = new MemoryCacheAdapter();

                    // http://msdn.microsoft.com/en-us/library/wcxyzt4d.aspx
                    //_cache = Activator.CreateInstance(Type.GetType(WebConfigSettings.CacheProviderType, _logger)) as ICache;

                    break;

            }

            _cacheProvider = new CacheProvider(_cache);
        }
        public static void EnsureIsStarted(Key key,
                                           ICacheItemRecalculationStrategy recalculationStrategy,
                                           MethodInterceptionArgs args,
                                           ICache cache)
        {
            var keyString = key.ToString();
            Ensure.That<NHelpfulException.FrameworkExceptions.ArgumentException>(keyString.Length.IsLessThanOrEqualTo(260),
                                                              "key must be less than 260 characters long.");

            try
            {
                bool createdNew;
                var mutex = new Mutex(false, MutexPrefix + keyString, out createdNew);
                if (createdNew)
                {
                    if (cache[keyString].IsNotNull())
                        return;
                    //item already in cache, assume thread already started TODO: possibly log this as an error

                    ThreadPool.QueueUserWorkItem(
                        o => recalculationStrategy.RunRoutine(key, args, cache, mutex, args.Proceed));

                    //NOTE: mutex.ReleaseMutex(); is not called because the mutex is only expected to be released upon closure of the application
                }
            }
            catch (Exception)
            {
                //log exception
                throw;
            }
        }
 public NetworkDispatcher(ConcurrentQueue<Request> queue, INetwork network, ICache cache, IResponseDelivery delivery)
 {
     this.mQueue = queue;
     this.mNetwork = network;
     this.mCache = cache;
     this.mDelivery = delivery;
 }
 /// <summary>
 /// Stops pruning.
 /// </summary>
 public void Stop()
 {
     _timer.Change(Timeout.Infinite, Timeout.Infinite);
     _timer.Dispose();
     _timer = null;
     Cache = null;
 }
		async Task<IAccessToken> IAccessTokenProvider.ProvisionAccessTokenAsync(
			IEnumerable<Claim> claims,
			IEnumerable<Scope> scopes,
			ICache cache
			) {

			if( cache == null ) {
				cache = new NullCache();
			}

			claims = claims.ToList();
			scopes = scopes.ToList();

			string cacheKey = TokenCacheKeyBuilder.BuildKey( claims, scopes );

			CacheResponse cacheResponse = await cache.GetAsync( cacheKey ).SafeAsync();

			if( cacheResponse.Success ) {
				SecurityToken securityToken = m_tokenHandler.ReadToken( cacheResponse.Value );
				if( securityToken.ValidTo > DateTime.UtcNow.Add( m_tokenRefreshGracePeriod ) ) {
					return new AccessToken( cacheResponse.Value );
				}
			}

			IAccessToken token =
				await m_accessTokenProvider.ProvisionAccessTokenAsync( claims, scopes ).SafeAsync();

			DateTime validTo = m_tokenHandler.ReadToken( token.Token ).ValidTo;

			await cache.SetAsync( cacheKey, token.Token, validTo - DateTime.UtcNow ).SafeAsync();
			return token;
		}
 public void testSetup()
 {
     _services = MockRepository.GenerateMock<IServiceLocator>();
     _cache = MockRepository.GenerateMock<ICache>();
     _bus = MockRepository.GenerateMock<IMessageBus>();
     _subject = new FileChangeConsumer(_services, _bus, _cache);
 }
Example #22
0
 public SubActivityDao(ISession session, 
     ISettingsProvider<SubSettings> subSettings,
     ICache cache)
     : base(session, subSettings)
 {
     _cache = cache;
 }
Example #23
0
 public AuthorizationContextCache(ICache cache, IControllerContextCache controllerContextCache, IControllerDescriptorCache controllerDescriptorCache, IRouteDataCache routeDataCache)
 {
     this.cache = cache;
     this.routeDataCache = routeDataCache;
     this.controllerContextCache = controllerContextCache;
     this.controllerDescriptorCache = controllerDescriptorCache;
 }
 public CobreGratisForTests(
     string clientAppIdentification, string authToken, ILogger logger, ICache cache,
     INetworkServices networkServices, IXmlSerializer xmlSerializer
     )
     : base(clientAppIdentification, authToken, logger, cache, networkServices, xmlSerializer)
 {
 }
 public RequestQueue(ICache cache, INetwork network, int threadPoolSize, IResponseDelivery delivery)
 {
     this.mCache = cache;
     this.mNetwork = network;
     this.mDispatchers = new NetworkDispatcher[threadPoolSize];
     this.mDelivery = delivery;
 }
Example #26
0
 public BaseController()
 {
     _accountService = DependencyResolver.Current.GetService<IAccountService>();
     _dictionaryService = DependencyResolver.Current.GetService<IDictionaryService>();
     CacheService = CacheProvider.Current.GetCache();
     _adminData = DependencyResolver.Current.GetService<IAdminScheduleService>();
 }
        public void SetUp()
        {
            _project = new Project(Path.GetFullPath("someProject.csproj"), new ProjectDocument(ProjectType.CSharp));
			_project.Value.SetOutputPath("");
			_project.Value.SetAssemblyName("someAssembly.dll");
            _bus = MockRepository.GenerateMock<IMessageBus>();
            _listGenerator = MockRepository.GenerateMock<IGenerateBuildList>();
            _configuration = MockRepository.GenerateMock<IConfiguration>();
            _buildRunner = MockRepository.GenerateMock<IBuildRunner>();
            _testRunner = MockRepository.GenerateMock<ITestRunner>();
			_testAssemblyValidator = MockRepository.GenerateMock<IDetermineIfAssemblyShouldBeTested>();
			_optimizer = MockRepository.GenerateMock<IOptimizeBuildConfiguration>();
            _fs = MockRepository.GenerateMock<IFileSystemService>();
            _cache = MockRepository.GenerateMock<ICache>();
            _runCache = MockRepository.GenerateMock<IRunResultCache>();
			_runInfo = new RunInfo(_project);
			_runInfo.ShouldBuild();
			_runInfo.SetAssembly(_project.Value.AssemblyName);
			_optimizer.Stub(o => o.AssembleBuildConfiguration(new string[] {})).IgnoreArguments().Return(new RunInfo[] { _runInfo });
            _preProcessor = MockRepository.GenerateMock<IPreProcessTestruns>();
            _preProcessor.Stub(x => x.PreProcess(null)).IgnoreArguments().Return(new PreProcessedTesRuns(null, new RunInfo[] { _runInfo }));
            var preProcessors = new IPreProcessTestruns[] { _preProcessor };
            var buildPreProcessor = MockRepository.GenerateMock<IPreProcessBuildruns>();
            buildPreProcessor.Stub(x => x.PreProcess(null)).IgnoreArguments().Return(new RunInfo[] { _runInfo });
            var buildPreProcessors = new IPreProcessBuildruns[] { buildPreProcessor };
            _removedTestLocator = MockRepository.GenerateMock<ILocateRemovedTests>();
            _buildSessionRunner = new BuildSessionRunner(new BuildConfiguration(null), _cache, _bus, _configuration, _buildRunner, buildPreProcessors, _fs, _runCache);
            _consumer = new ProjectChangeConsumer(_bus, _listGenerator, _configuration, _buildSessionRunner, new ITestRunner[] { _testRunner }, _testAssemblyValidator, _optimizer, preProcessors, _removedTestLocator);
        }
        private static void RunCacheTests(ICache cache)
        {
            cache.Insert("ByteArray", new byte[] {0, 1, 2, 3}, CachePriority.Normal);
            cache.Insert("String", "Hello World", CachePriority.Normal);
            cache.Insert("Object", new TestObject("Test Object", 1234), CachePriority.Normal);

            var byteArray = cache.Lookup("ByteArray");
            Assert.IsNotNull(byteArray);
            Assert.AreEqual(4, byteArray.Length);
            for (int i = 0; i < 4; i++) Assert.AreEqual(i, byteArray[i]);

            var cachedString = cache.Lookup<string>("String");
            Assert.IsNotNull(cachedString);
            Assert.AreEqual("Hello World", cachedString);

            var cachedObject = cache.Lookup<TestObject>("Object");
            Assert.IsNotNull(cachedObject);
            Assert.AreEqual("Test Object", cachedObject.StringValue);
            Assert.AreEqual(1234, cachedObject.LongValue);

            cache.Remove("Object");
            Assert.IsNull(cache.Lookup("Object"));
            Assert.IsFalse(cache.ContainsKey("Object"));
            Assert.IsTrue(cache.ContainsKey("String"));
        }
Example #29
0
        static void Main(string[] args)
        {
            Console.WriteLine("Gnosis Repository Test");

            try
            {
                artistCache = new Cache<Artist>();
                workCache = new Cache<Work>();
                artistStore = new SQLiteArtistDatabase();
                workStore = new SQLiteWorkDatabase(artistCache, workCache);
                repository = new Repository(artistCache, artistStore, workCache, workStore);
                repository.Initialize();

                //cache = new GlobalCache();
                //database = new GlobalDatabase();
                //database.Initialize(cache);

                //repository = new GlobalRepository(cache, database);

                //AddAlbum();
                DisplayInfo();

                Console.WriteLine("Artist Count: {0}", artistCache.Entities.Count());
                Console.WriteLine("Work Count: {0}", workCache.Entities.Count());
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR");
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }

            Console.WriteLine("Press ENTER to close");
            Console.ReadLine();
        }
 public Database(IConfiguration config, ICache cache)
 {
     Config = config;
     Cache  = cache;
 }
Example #31
0
 internal Dispatcher(Context context, Handler mainThreadHandler, IExecutorService service, ICache <Bitmap> cache, IDownloader <Bitmap> downloader)
 {
     m_DipatcherThread = new DispatcherThread();
     m_DipatcherThread.Start();
     m_Handler           = new DispatcherHandler(m_DipatcherThread.Looper, this);
     m_Context           = context;
     m_MainThreadHandler = mainThreadHandler;
     m_Cache             = cache;
     m_Downloader        = downloader;
     m_Service           = service;
     m_AirplaneMode      = AndroidUtils.IsAirplaneModeOn(m_Context);
     m_Receiver          = new NetworkBroadcastReceiver(this);
     m_Receiver.Register();
 }
 public AddOrUpdateSprintHandler(IBacklogContext context, ICache cache)
 {
     _context = context;
     _cache   = cache;
 }
Example #33
0
 public GetContactByIdHandler(VendorCollectionContext context, ICache cache)
 {
     _context = context;
     _cache   = cache;
 }
Example #34
0
 public UserController(IUserService userService, ICache <User> cache)
 {
     _userService  = userService;
     _cacheService = cache;
 }
Example #35
0
        /// <summary>
        /// Validates the query results.
        /// </summary>
        /// <param name="cache">Cache.</param>
        /// <param name="qry">Query.</param>
        /// <param name="exp">Expected keys.</param>
        /// <param name="keepBinary">Keep binary flag.</param>
        private static void ValidateQueryResults(ICache <int, QueryPerson> cache, QueryBase qry, HashSet <int> exp,
                                                 bool keepBinary)
        {
            if (keepBinary)
            {
                var cache0 = cache.WithKeepBinary <int, IBinaryObject>();

                using (var cursor = cache0.Query(qry))
                {
                    HashSet <int> exp0 = new HashSet <int>(exp);
                    var           all  = new List <ICacheEntry <int, object> >();

                    foreach (var entry in cursor.GetAll())
                    {
                        all.Add(entry);

                        Assert.AreEqual(entry.Key.ToString(), entry.Value.GetField <string>("name"));
                        Assert.AreEqual(entry.Key, entry.Value.GetField <int>("age"));

                        exp0.Remove(entry.Key);
                    }

                    AssertMissingExpectedKeys(exp0, cache, all);
                }

                using (var cursor = cache0.Query(qry))
                {
                    HashSet <int> exp0 = new HashSet <int>(exp);
                    var           all  = new List <ICacheEntry <int, object> >();

                    foreach (var entry in cursor)
                    {
                        all.Add(entry);

                        Assert.AreEqual(entry.Key.ToString(), entry.Value.GetField <string>("name"));
                        Assert.AreEqual(entry.Key, entry.Value.GetField <int>("age"));

                        exp0.Remove(entry.Key);
                    }

                    AssertMissingExpectedKeys(exp0, cache, all);
                }
            }
            else
            {
                using (var cursor = cache.Query(qry))
                {
                    HashSet <int> exp0 = new HashSet <int>(exp);
                    var           all  = new List <ICacheEntry <int, object> >();

                    foreach (var entry in cursor.GetAll())
                    {
                        all.Add(entry);

                        Assert.AreEqual(entry.Key.ToString(), entry.Value.Name);
                        Assert.AreEqual(entry.Key, entry.Value.Age);

                        exp0.Remove(entry.Key);
                    }

                    AssertMissingExpectedKeys(exp0, cache, all);
                }

                using (var cursor = cache.Query(qry))
                {
                    HashSet <int> exp0 = new HashSet <int>(exp);
                    var           all  = new List <ICacheEntry <int, object> >();

                    foreach (var entry in cursor)
                    {
                        all.Add(entry);

                        Assert.AreEqual(entry.Key.ToString(), entry.Value.Name);
                        Assert.AreEqual(entry.Key, entry.Value.Age);

                        exp0.Remove(entry.Key);
                    }

                    AssertMissingExpectedKeys(exp0, cache, all);
                }
            }
        }
Example #36
0
        public async Task DisconnectMostRemoteAfterBuildReturnsMostRemoteCacheDeterminism()
        {
            string cacheId   = "MutlipleCacheRemote";
            ICache testCache = await InitializeCacheAsync(NewCache(cacheId, true, false, true)).SuccessAsync();

            VerticalCacheAggregator lowerVert = testCache as VerticalCacheAggregator;

            XAssert.IsNotNull(lowerVert);

            CallbackCacheWrapper callbackCache = lowerVert.RemoteCache as CallbackCacheWrapper;

            XAssert.IsNotNull(callbackCache);

            VerticalCacheAggregator upperVert = callbackCache.WrappedCache as VerticalCacheAggregator;

            XAssert.IsNotNull(upperVert);

            ICacheSession session = await testCache.CreateSessionAsync().SuccessAsync();

            FullCacheRecord cacheRecord = await FakeBuild.DoPipAsync(session, "Test Pip");

            VerticalAggregatorDisconnectTests.DisconnectCache(upperVert.RemoteCache);

            // Now query each cache, and verify only the remote content is in each.
            var remoteDeterminism = CacheDeterminism.ViaCache(upperVert.RemoteCache.CacheGuid, CacheDeterminism.NeverExpires);

            foreach (var currentCache in new Tuple <ICache, CacheDeterminism, string, int>[]
            {
                new Tuple <ICache, CacheDeterminism, string, int>(testCache, remoteDeterminism, lowerVert.LocalCache.CacheId, 2),
                new Tuple <ICache, CacheDeterminism, string, int>(lowerVert.LocalCache, remoteDeterminism, lowerVert.LocalCache.CacheId, 1),
                new Tuple <ICache, CacheDeterminism, string, int>(upperVert.LocalCache, remoteDeterminism, upperVert.LocalCache.CacheId, 1),
                new Tuple <ICache, CacheDeterminism, string, int>(upperVert.RemoteCache, remoteDeterminism, upperVert.RemoteCache.CacheId, 1),
            })
            {
                await ValidateItemsInCacheAsync(
                    currentCache.Item1,
                    cacheRecord.StrongFingerprint.WeakFingerprint,
                    new List <CasHash>(cacheRecord.CasEntries),
                    currentCache.Item2,
                    cacheRecord.StrongFingerprint.CasElement,
                    currentCache.Item3,
                    currentCache.Item4);
            }

            // And make sure it flips back on re-connect.
            remoteDeterminism = CacheDeterminism.ViaCache(upperVert.RemoteCache.CacheGuid, CacheDeterminism.NeverExpires);
            VerticalAggregatorDisconnectTests.ConnectCache(upperVert.RemoteCache);

            foreach (var currentCache in new Tuple <ICache, CacheDeterminism, string, int>[]
            {
                new Tuple <ICache, CacheDeterminism, string, int>(testCache, CacheDeterminism.ViaCache(upperVert.RemoteCache.CacheGuid, CacheDeterminism.NeverExpires), lowerVert.LocalCache.CacheId, 3),
                new Tuple <ICache, CacheDeterminism, string, int>(lowerVert.LocalCache, CacheDeterminism.ViaCache(upperVert.RemoteCache.CacheGuid, CacheDeterminism.NeverExpires), lowerVert.LocalCache.CacheId, 1),
                new Tuple <ICache, CacheDeterminism, string, int>(upperVert.LocalCache, CacheDeterminism.ViaCache(upperVert.RemoteCache.CacheGuid, CacheDeterminism.NeverExpires), upperVert.LocalCache.CacheId, 1),
                new Tuple <ICache, CacheDeterminism, string, int>(upperVert.RemoteCache, remoteDeterminism, upperVert.RemoteCache.CacheId, 1),
            })
            {
                await ValidateItemsInCacheAsync(
                    currentCache.Item1,
                    cacheRecord.StrongFingerprint.WeakFingerprint,
                    new List <CasHash>(cacheRecord.CasEntries),
                    currentCache.Item2,
                    cacheRecord.StrongFingerprint.CasElement,
                    currentCache.Item3,
                    currentCache.Item4);
            }

            await testCache.ShutdownAsync().SuccessAsync();
        }
 public RemoveAgileTeamMemberHandler(IBacklogContext context, ICache cache)
 {
     _context = context;
     _cache   = cache;
 }
Example #38
0
        public override void SetUp()
        {
            mockInnerCache = Mocks.CreateMock <ICache>();

            base.SetUp();
        }
 public Handler(IAppDbContext context, ICache cache)
 {
     _context = context;
     _cache   = cache;
 }
Example #40
0
 public DynamicActionResultAttribute()
 {
     _propertyCache =
         DependencyResolver.Current.Get <ICacheFactory>().GetCache <List <JsonField> >("BaseControllerJsonFields");
 }
Example #41
0
 public MenuServices(IMenuRepository menuRepository, IUnitOfWork unitOfWork, IEFCoreRepository <RoleMenuEntity, Guid> roleMenuRepository, IMenuFunctionRepository menuFunction, IPrincipal principal, UserManager <User> userManager, RoleManager <Role> roleManager, IEFCoreRepository <UserRole, Guid> repositoryUserRole, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, ICache cache)
 {
     _menuRepository     = menuRepository;
     _roleMenuRepository = roleMenuRepository;
     this._menuFunction  = menuFunction;
     _unitOfWork         = unitOfWork;
     _iIdentity          = principal.Identity;
     _userManager        = userManager;
     _roleManager        = roleManager;
     _repositoryUserRole = repositoryUserRole;
     _logger             = loggerFactory.CreateLogger <MenuServices>();
     _cache = cache;
 }
 public BannedPhrasesProvider(ILogger <BannedPhrasesProvider> logger, IReferenceDataReader referenceDataReader, ICache cache, ITimeProvider timeProvider)
 {
     _logger = logger;
     _referenceDataReader = referenceDataReader;
     _cache        = cache;
     _timeProvider = timeProvider;
 }
 public IfNoSubItemsInInstantPackageHide(ICache cache)
     : base(cache)
 {
 }
Example #44
0
 public LanguageProvider(IQueryable <FeedItem> feedItems, ICache cache)
 {
     _feedItems = feedItems;
     _cache     = cache;
 }
Example #45
0
        // This section covers all the functions that depend on the type of group we're talking about.

        internal static T[] GroupsInCache(ICache cache)
        {
            return(typeof(T) == typeof(VMSS)? cache.VMSSs as T[] : cache.VM_appliances as T[]);
        }
Example #46
0
        private ICacheDependencyManager GetCacheDependencyManager(CacheConfig config, ICache cache)
        {
            ICacheDependencyManager dependencyMgr = null;
            var normalisedDependencyManagerConfig = !string.IsNullOrWhiteSpace(config.DependencyManagerToUse) ? config.DependencyManagerToUse.ToLowerInvariant() : string.Empty;

            switch (normalisedDependencyManagerConfig)
            {
            case CacheDependencyManagerTypes.Default:
                dependencyMgr = GetRedisCacheDependencyManagerIfApplicable(config, cache);
                break;

            case CacheDependencyManagerTypes.Redis:
                dependencyMgr = GetRedisCacheDependencyManagerIfApplicable(config, cache);
                break;

            case CacheDependencyManagerTypes.Generic:
                dependencyMgr = new GenericDependencyManager(cache, _logger, config);
                break;

            case CacheDependencyManagerTypes.Unspecified:
                // try and determine what one to use based on the cache type
                dependencyMgr = GetRedisCacheDependencyManagerIfApplicable(config, cache);
                break;

            default:
                dependencyMgr = new GenericDependencyManager(cache, _logger, config);
                break;
            }
            return(dependencyMgr);
        }
Example #47
0
        public void Intercept(IInvocation invocation)
        {
            IEnumerable <object> clearCacheItems         = null;
            IEnumerable <object> clearCacheItemsStarWith = null;

            object[] attrs      = invocation.Request.Method.GetCustomAttributes(typeof(BaseCacheAttribute), true);
            object   cacheItems = attrs.SingleOrDefault(x => x.GetType().Name == "CacheItemPropertiesAttribute");

            if (cacheItems == null)
            {
                clearCacheItems =
                    attrs.Where(x => x.GetType().Name == "ClearCacheItemPropertiesAttribute").AsEnumerable();
                clearCacheItemsStarWith =
                    attrs.Where(x => x.GetType().Name == "ClearCacheKeysStartingWithAttribute").AsEnumerable();
            }

            if (attrs.Length == 0)
            {
                invocation.Proceed();
                return;
            }

            if (cacheItems != null)
            {
                BaseCacheAttribute cacheItemProperty = cacheItems as BaseCacheAttribute;
                ICache             appCache          = CacheManager.GetCache();

                CacheItemPropertiesAttribute cacheItemProperties = cacheItemProperty as CacheItemPropertiesAttribute;
                string key = getKey(invocation, cacheItemProperties);

                if (appCache.Get(key) == null)
                {
                    invocation.Proceed();
                    DateTime cacheTimeSpan =
                        DateTime.Now.AddMinutes(cacheItemProperties.PermissionCacheMinutes > 0
                            ? cacheItemProperties.PermissionCacheMinutes
                            : 60);

                    appCache.Add(key, cacheTimeSpan, invocation.ReturnValue);
                }
                else
                {
                    invocation.ReturnValue = appCache.Get(key);
                }
            }

            if (clearCacheItems != null)
            {
                foreach (object attr in clearCacheItems)
                {
                    BaseCacheAttribute cacheItemProperty = attr as BaseCacheAttribute;
                    ICache             appCache          = CacheManager.GetCache();

                    string key = getClearKey(invocation, cacheItemProperty as ClearCacheItemPropertiesAttribute);

                    string[] keys = appCache.GetKeys();

                    keys.Where(x => x.Contains(key)).ToList().ForEach(appCache.InvalidateCacheItem);

                    appCache.InvalidateCacheItem(key);
                }

                invocation.Proceed();
            }

            if (clearCacheItemsStarWith != null)
            {
                foreach (object attr in clearCacheItemsStarWith)
                {
                    BaseCacheAttribute cacheItemProperty = attr as BaseCacheAttribute;
                    ICache             appCache          = CacheManager.GetCache();

                    string key = getClearKeyStartsWith(cacheItemProperty as ClearCacheKeysStartingWithAttribute);

                    string[] keys = appCache.GetKeys();

                    List <string> cacheItemsRemoved = keys.Where(x => x.StartsWith(key)).ToList();

                    foreach (string item in cacheItemsRemoved)
                    {
                        appCache.InvalidateCacheItem(item);
                    }
                }
            }
        }
Example #48
0
 public Cache(TableCellCache tableCache, ICache baseCache, int hashSize, int maxSize)
     : base(baseCache)
 {
     this.tableCache = tableCache;
     this.hashSize   = hashSize;
 }
Example #49
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="repo">The current repository</param>
 /// <param name="paramService">The current param service</param>
 /// <param name="storage">The current storage manager</param>
 /// <param name="cache">The optional model cache</param>
 /// <param name="processor">The optional image processor</param>
 public MediaService(IMediaRepository repo, IParamService paramService, IStorage storage, IImageProcessor processor = null, ICache cache = null)
 {
     _repo         = repo;
     _paramService = paramService;
     _storage      = storage;
     _processor    = processor;
     _cache        = cache;
 }
 public RoleMenuCacheDeleteHandler(IServiceProvider serviceProvider, ICache cache) : base(cache)
 {
     _serviceProvider = serviceProvider;
 }
Example #51
0
        private ICacheDependencyManager GetRedisCacheDependencyManagerIfApplicable(CacheConfig config, ICache cache)
        {
            ICacheDependencyManager dependencyMgr = null;
            var redisCache = cache as RedisCacheAdapter;

            if (redisCache != null)
            {
                dependencyMgr = new RedisDependencyManager(cache, _logger, redisCache.RedisDatabase, config);
            }
            else
            {
                dependencyMgr = new GenericDependencyManager(cache, _logger, config);
            }
            return(dependencyMgr);
        }
 public AdReadRepository(IConnectionFactory connectionFactory, ICache <IEnumerable <Ad> > cacheRepository)
 {
     this.connection      = connectionFactory;
     this.cacheRepository = cacheRepository;
 }
 public GithubService(ICache cachingService, IGithubDataRepository dataRepository)
 {
     _cachingService = cachingService;
     _dataRepository = dataRepository;
 }
Example #54
0
 public SampleTypeServiceBase(ISampleTypeRepository rep, ICache cache, CurrentUser user)
     : base(cache)
 {
     this._rep  = rep;
     this._user = user;
 }
Example #55
0
 public IImageDrawNode CreateImageDrawNode(IImageShape image, IShapeStyle style, IImageCache imageCache, ICache <string, IDisposable> bitmapCache)
 {
     return(new ImageDrawNode(image, style, imageCache, bitmapCache));
 }
Example #56
0
 public ModelCacheFac(ICacheOp cacheOp, ICache cache)
 {
     type    = typeof(T);
     Cache   = cache;
     CacheOp = cacheOp;
 }
 static CacheManager()
 {
     cache = (ICache)Activator.CreateInstance(typeof(MemoryCache));
 }
Example #58
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="api">The current api</param>
 /// <param name="connection">The current db connection</param>
 /// <param name="cache">The optional model cache</param>
 public SiteRepository(Api api, IDbConnection connection, ICache cache = null)
     : base(connection, "Piranha_Sites", "Title", modelCache: cache)
 {
     this.api = api;
 }
 public DirectoryWatcher(IMessageBus bus, IWatchValidator validator, IConfiguration configuration, IHandleDelayedConfiguration delayedConfigurer, IWatchPathLocator watchPathLocator, IApplicatonLauncher launcer, ICache cache, IMarkProjectsForRebuild rebuildMarker, ISolutionChangeConsumer solutionHanlder)
 {
     _bus               = bus;
     _validator         = validator;
     _configuration     = configuration;
     _delayedConfigurer = delayedConfigurer;
     _watchPathLocator  = watchPathLocator;
     _launcer           = launcer;
     _cache             = cache;
     _rebuildMarker     = rebuildMarker;
     _solutionHanlder   = solutionHanlder;
     if (!_configuration.StartPaused)
     {
         Resume();
     }
 }
Example #60
-1
 /// <summary>
 /// Static constructor.
 /// </summary>
 static CacheAttribute()
 {
     if (!PostSharpEnvironment.IsPostSharpRunning)
     {
         Cache = new AzureCache();
     }
 }