コード例 #1
0
 public async Task InvokeAsync(HttpContext context, ILocalCache localCache)
 {
     using (localCache.StartContext())
     {
         await next(context);
     }
 }
コード例 #2
0
ファイル: RuleRunnerGrain.cs プロジェクト: julienM77/squidex
        public RuleRunnerGrain(
            IGrainState <State> state,
            IAppProvider appProvider,
            ILocalCache localCache,
            IEventStore eventStore,
            IEventDataFormatter eventDataFormatter,
            IRuleEventRepository ruleEventRepository,
            IRuleService ruleService,
            ISemanticLog log)
        {
            Guard.NotNull(state, nameof(state));
            Guard.NotNull(appProvider, nameof(appProvider));
            Guard.NotNull(localCache, nameof(localCache));
            Guard.NotNull(eventStore, nameof(eventStore));
            Guard.NotNull(eventDataFormatter, nameof(eventDataFormatter));
            Guard.NotNull(ruleEventRepository, nameof(ruleEventRepository));
            Guard.NotNull(ruleService, nameof(ruleService));
            Guard.NotNull(log, nameof(log));

            this.state               = state;
            this.appProvider         = appProvider;
            this.localCache          = localCache;
            this.eventStore          = eventStore;
            this.eventDataFormatter  = eventDataFormatter;
            this.ruleEventRepository = ruleEventRepository;
            this.ruleService         = ruleService;
            this.log = log;
        }
コード例 #3
0
 public LocalCacheEventsWrapper(
     LocalCacheEventsWrapperConfig <TKey, TValue> config,
     ILocalCache <TKey, TValue> innerCache)
     : base(innerCache)
 {
     _config = config;
 }
コード例 #4
0
 public AppProvider(ILocalCache localCache, IAppsIndex indexForApps, IRulesIndex indexRules, ISchemasIndex indexSchemas)
 {
     this.localCache   = localCache;
     this.indexForApps = indexForApps;
     this.indexRules   = indexRules;
     this.indexSchemas = indexSchemas;
 }
コード例 #5
0
 public JobMasterService(IEncompassEventRepository encompassEventRepository, IJobMasterConfiguration jobPickerConfiguration,
                         ILocalCache localCache)
 {
     _encompassEventRepository = encompassEventRepository;
     _jobPickerConfiguration   = jobPickerConfiguration;
     _cache = localCache;
 }
コード例 #6
0
        private static void AssertCache(ILocalCache cache, string key, object expectedValue, bool expectedFound)
        {
            var found = cache.TryGetValue(key, out var value);

            Assert.Equal(expectedFound, found);
            Assert.Equal(expectedValue, value);
        }
コード例 #7
0
        public IPipeValidator <TModel> ImportLocalCache(ILocalCache cache)
        {
            CheckCacheObject();

            _externalCache = new Optional <ILocalCache>(cache);
            return(this);
        }
コード例 #8
0
        public AssetFolderResolver(ILocalCache localCache, IAssetQueryService assetQuery)
        {
            Guard.NotNull(localCache, nameof(localCache));
            Guard.NotNull(assetQuery, nameof(assetQuery));

            this.localCache = localCache;
            this.assetQuery = assetQuery;
        }
 public CacheController(
     IRequestContext context,
     ILocalCache localCache)
 {
     _clientFactory = new CacheCommunicationClientFactory(context, localCache);
     _context       = context;
     _localCache    = localCache;
 }
コード例 #10
0
        public AppProvider(IGrainFactory grainFactory, ILocalCache localCache)
        {
            Guard.NotNull(grainFactory, nameof(grainFactory));
            Guard.NotNull(localCache, nameof(localCache));

            this.grainFactory = grainFactory;
            this.localCache   = localCache;
        }
コード例 #11
0
 public StrategyManagementService(ILogger <StrategyManagementService> logger,
                                  IStrategyTradingService strategyTradingService,
                                  ILocalCache localCache)
     : base(TimeSpan.FromMilliseconds(TickFrequencyMilliseconds), logger)
 {
     _strategyTradingService = strategyTradingService;
     _localCache             = localCache;
 }
コード例 #12
0
 public LocalCacheAdapter(
     ILocalCache <TKey, TValue> innerCache,
     Func <TKey, bool> skipCacheGetPredicate,
     Func <TKey, TValue, bool> skipCacheSetPredicate)
 {
     _innerCache            = innerCache;
     _skipCacheGetPredicate = skipCacheGetPredicate;
     _skipCacheSetPredicate = skipCacheSetPredicate;
 }
コード例 #13
0
 public Rebuilder(
     ILocalCache localCache,
     IEventStore eventStore,
     IServiceProvider serviceProvider)
 {
     this.eventStore      = eventStore;
     this.serviceProvider = serviceProvider;
     this.localCache      = localCache;
 }
コード例 #14
0
 public static void Set <TOuterKey, TInnerKey, TValue>(
     this ILocalCache <TOuterKey, TInnerKey, TValue> cache,
     TOuterKey outerKey,
     TInnerKey innerKey,
     TValue value,
     TimeSpan timeToLive)
 {
     cache.SetMany(outerKey, new[] { new KeyValuePair <TInnerKey, TValue>(innerKey, value) }, timeToLive);
 }
コード例 #15
0
 public Rebuilder(
     ILocalCache localCache,
     IStore <Guid> store,
     IEventStore eventStore)
 {
     this.eventStore = eventStore;
     this.localCache = localCache;
     this.store      = store;
 }
コード例 #16
0
ファイル: ThumbnailOp.cs プロジェクト: mamasha/tests
        private ThumbnailOp(ILocalCache <byte[]> cache, IAsyncFlow <byte[]> async)
        {
            var log = TopicLogger.New("thumbnail-op");

            _log     = log;
            _cache   = cache;
            _async   = async;
            _helpers = ImageUtilities.New(log);
        }
コード例 #17
0
 public DocumentService(IEncompassClient encompassClient, IRedisCacheApiClient redisCacheClient, ILocalCache cache,
                        IEncompassDocumentRepository documentRepository, IDocumentWorkerConfiguration documentWorkerConfiguration)
 {
     _encompassClient             = encompassClient;
     _redisCacheClient            = redisCacheClient;
     _cache                       = cache;
     _documentRepository          = documentRepository;
     _documentWorkerConfiguration = documentWorkerConfiguration;
 }
 public CacheCommunicationClientFactory(
     IRequestContext context,
     ILocalCache localCache,
     IServicePartitionResolver resolver = null,
     IEnumerable <IExceptionHandler> exceptionHandlers = null)
     : base(resolver, CreateExceptionHandlers(context, exceptionHandlers))
 {
     _localCache = localCache;
     _context    = context;
 }
コード例 #19
0
 public static async Task <T> GetOrCreateAsync <T>(this ILocalCache cache, object key, Func <Task <T> > creator)
 {
     if (cache.TryGetValue(key, out var value))
     {
         if (value is T typed)
         {
             return(typed);
         }
         else
         {
             return(default !);
コード例 #20
0
 public Rebuilder(
     ILocalCache localCache,
     IEventStore eventStore,
     IServiceProvider serviceProvider,
     ILogger <Rebuilder> log)
 {
     this.eventStore      = eventStore;
     this.serviceProvider = serviceProvider;
     this.localCache      = localCache;
     this.log             = log;
 }
コード例 #21
0
 public Rebuilder(
     FieldRegistry fieldRegistry,
     ILocalCache localCache,
     IStore <Guid> store,
     IEventStore eventStore)
 {
     this.fieldRegistry = fieldRegistry;
     this.eventStore    = eventStore;
     this.localCache    = localCache;
     this.store         = store;
 }
コード例 #22
0
 public DbContextScope(ILocalCache cache, ISettingsStorage settingsStorage) {
     _parentScope = GetAmbientScope();
     _cache = cache;
     if (_parentScope == null) {
         _gameContext = new Lazy<IGameContext>(Factory);
         _settingsContext = new Lazy<ISettingsStorage>(() => settingsStorage);
         _contentLinkContext = new Lazy<IContentFolderLinkContext>(() => new ContentFolderLinkContext(Common.Paths.LocalDataPath.GetChildFileWithName("folderlink.json")));
     } else
         _nested = true;
     SetAmbientScope(this);
 }
コード例 #23
0
        public static bool TryGetCache <T>(this ILocalCache cache, string cacheKey, out T val, DateTime?expiry = null)
        {
            object obj;

            if (cache.TryGetCache(cacheKey, out obj, expiry))
            {
                val = (T)obj;
                return(true);
            }
            val = default(T);
            return(false);
        }
コード例 #24
0
        public static KeyValuePair <TKey, TValue>[] GetMany <TKey, TValue>(
            this ILocalCache <TKey, TValue> cache,
            ReadOnlySpan <TKey> keys)
        {
            using var memoryOwner = MemoryPool <KeyValuePair <TKey, TValue> > .Shared.Rent(keys.Length);

            var span = memoryOwner.Memory.Span;

            var countFound = cache.GetMany(keys, span);

            return(span.Slice(0, countFound).ToArray());
        }
コード例 #25
0
ファイル: ILGen.cs プロジェクト: clintonmead/Theraot
 internal static void EmitArray <T>(this ILGenerator il, T[] items, ILocalCache locals)
 {
     il.EmitPrimitive(items.Length);
     il.Emit(OpCodes.Newarr, typeof(T));
     for (var i = 0; i < items.Length; i++)
     {
         il.Emit(OpCodes.Dup);
         il.EmitPrimitive(i);
         il.TryEmitConstant(items[i], typeof(T), locals);
         il.EmitStoreElement(typeof(T));
     }
 }
コード例 #26
0
ファイル: AppProvider.cs プロジェクト: Jaben/squidex
        public AppProvider(ILocalCache localCache, IAppsIndex indexForApps, IRulesIndex indexRules, ISchemasIndex indexSchemas)
        {
            Guard.NotNull(indexForApps, nameof(indexForApps));
            Guard.NotNull(indexRules, nameof(indexRules));
            Guard.NotNull(indexSchemas, nameof(indexSchemas));
            Guard.NotNull(localCache, nameof(localCache));

            this.localCache   = localCache;
            this.indexForApps = indexForApps;
            this.indexRules   = indexRules;
            this.indexSchemas = indexSchemas;
        }
コード例 #27
0
ファイル: Rebuilder.cs プロジェクト: NagRaj0077/SquidexSample
        public Rebuilder(
            ILocalCache localCache,
            IStore <Guid> store,
            IEventStore eventStore)
        {
            Guard.NotNull(localCache);
            Guard.NotNull(store);
            Guard.NotNull(eventStore);

            this.eventStore = eventStore;
            this.localCache = localCache;
            this.store      = store;
        }
コード例 #28
0
        public static T GetOrCreate <T>(this ILocalCache cache, object key, Func <T> task)
        {
            if (cache.TryGetValue(key, out var value) && value is T typedValue)
            {
                return(typedValue);
            }

            typedValue = task();

            cache.Add(key, typedValue);

            return(typedValue);
        }
コード例 #29
0
 public CacheCommunicationClient(
     CancellationToken token,
     IRequestContext context,
     HttpClient httpClient,
     string address,
     ILocalCache localCache)
 {
     this.HttpClient        = httpClient;
     this.Url               = new Uri(address);
     this.LocalCache        = localCache;
     this.CancellationToken = token;
     _context               = context;
 }
コード例 #30
0
 public DbContexts(ILocalCache cache, Func <ApiContext> apiCacheCreator, ISettingsStorage settingsStorage)
 {
     _cache              = cache;
     _apiCacheCreator    = apiCacheCreator;
     _gameContext        = new Lazy <IGameContext>(Factory);
     _apiContext         = new Lazy <IApiContext>(ApiFactory);
     _settingsContext    = new Lazy <ISettingsStorage>(() => settingsStorage);
     _contentLinkContext =
         new Lazy <IContentFolderLinkContext>(
             () =>
             new ContentFolderLinkContext(
                 Common.Paths.LocalDataPath.GetChildFileWithName("folderlink.json")));
 }
コード例 #31
0
        public Rebuilder(
            ILocalCache localCache,
            IEventStore eventStore,
            IServiceProvider serviceProvider)
        {
            Guard.NotNull(localCache, nameof(localCache));
            Guard.NotNull(serviceProvider, nameof(serviceProvider));
            Guard.NotNull(eventStore, nameof(eventStore));

            this.eventStore      = eventStore;
            this.serviceProvider = serviceProvider;
            this.localCache      = localCache;
        }
コード例 #32
0
 public DbContextScope(ILocalCache cache, Func<ApiContext> apiContextCreator, ISettingsStorage settingsStorage) {
     _parentScope = GetAmbientScope();
     if (_parentScope == null)
         _contexts = new DbContexts(cache, apiContextCreator, settingsStorage);
     else {
         _contexts = _parentScope._contexts;
         _nested = true;
     }
     SetAmbientScope(this);
 }
コード例 #33
0
 public DbContexts(ILocalCache cache, Func<ApiContext> apiCacheCreator, ISettingsStorage settingsStorage) {
     _cache = cache;
     _apiCacheCreator = apiCacheCreator;
     _gameContext = new Lazy<IGameContext>(Factory);
     _apiContext = new Lazy<IApiContext>(ApiFactory);
     _settingsContext = new Lazy<ISettingsStorage>(() => settingsStorage);
     _contentLinkContext =
         new Lazy<IContentFolderLinkContext>(
             () =>
                 new ContentFolderLinkContext(
                     Common.Paths.LocalDataPath.GetChildFileWithName("folderlink.json")));
 }
コード例 #34
0
 public ContentClient()
 {
     _localCache = new LocalCache<Content>();
 }
コード例 #35
0
 public ContentClient(IContentService service, ILocalCache<Content> localCache)
 {
     _service = service;
     _localCache = localCache;
 }
コード例 #36
0
 public void Setup()
 {
     _localCache = MockRepository.GenerateMock<ILocalCache>();
     _searchService = MockRepository.GenerateMock<ITwitterizerSearchService>();
 }
コード例 #37
0
 public GameContextJsonImplementation(ILocalCache cache) {
     _cache = cache;
 }
コード例 #38
0
 public MarkupClient()
 {
     _localCache = new LocalCache<string>();
 }
コード例 #39
0
 public TwitterSearchClient(ILocalCache localCache, ITwitterizerSearchService searchService)
 {
     _localCache = localCache;
     _searchService = searchService;
 }
コード例 #40
0
 public MarkupClient(IMarkupService service)
 {
     _service = service;
     _localCache = new LocalCache<string>();
 }
コード例 #41
0
 public DownloadCacheManager(ILocalCache localCache) {
     _localCache = localCache;
 }
コード例 #42
0
 public SettingsStorage(ILocalCache localCache, ISecureCache roamingSecureCache, IUserCache roamingCache) {
     _localCache = localCache;
     _roamingSecureCache = roamingSecureCache;
     _roamingCache = roamingCache;
     _settings = new Lazy<Settings>(() => Task.Run(() => LoadSettings()).Result);
 }
コード例 #43
0
 public MarkupClient(IMarkupService service, ILocalCache<string> localCache)
 {
     _service = service;
     _localCache = localCache;
 }