public EntityManager(IMemoryCacheService <T> cacheService, string connectionString, string commandText)
 {
     _cacheService     = cacheService;
     _commandText      = commandText;
     _connectionString = connectionString;
     _key = $"{typeof(T).Name}_Cache_{DateTime.UtcNow.Day}";
 }
Ejemplo n.º 2
0
 public ActivityLogService(
     MongoDbContext dbContext,
     IMemoryCacheService memoryCacheService)
 {
     _dbContext          = dbContext;
     _memoryCacheService = memoryCacheService;
 }
Ejemplo n.º 3
0
        public override async Task <HashSet <string> > GetSetAsync(
            string key,
            Func <IEnumerable <string> > factory = null
            )
        {
            var result = IMemoryCacheService.Get <HashSet <string> >(key);

            if (result != null)
            {
                return(result);
            }

            var values = await IRedisGatewayService.GetSetAsync <string>(key);

            if (!values.HasContent())
            {
                values = factory.Invoke().ToHashSet();
            }

            await IRedisGatewayService.SetSetAsync(key, values);

            result = values.ToHashSet();

            if (_UseCacheAside)
            {
                var entryOptions = new CacheOptions <HashSet <string> >(expirationType: CacheExpirationType.NotRemoveable);
                IMemoryCacheService.Set(key, result, entryOptions);
            }

            return(result);
        }
        public ConfigurationService(IFileManager fileManager, IMemoryCacheService memoryCacheService)
        {
            _fileManager        = fileManager;
            _memoryCacheService = memoryCacheService;
            _lockObject         = new object();

            LoadValuesIntoCache();
        }
Ejemplo n.º 5
0
        public InMemoryStoreTesting(IMemoryCacheService memoryCacheService, IWeatherService weatherService)
        {
            this.MemoryCacheService = memoryCacheService;
            this.WeatherService     = weatherService;
            this.randomGenerator    = new Random();

            this.stream = new StreamWriter("in memory tests.txt", true);
        }
Ejemplo n.º 6
0
 public ExpensesService(IDataRepository <Expense> expensesRepository,
                        IDataRepository <ExpenseType> expenseTypeRepository,
                        IMemoryCacheService <IEnumerable <ExpenseType> > cacheService)
 {
     _expensesRepository    = expensesRepository;
     _expenseTypeRepository = expenseTypeRepository;
     _cacheService          = cacheService;
 }
Ejemplo n.º 7
0
 public HealthChecksService(ISyrinxCamundaClientService camundaService, IMemoryCacheService memoryCacheService, IPortalSettingsStore portalSettingsStore,
                            IPortalSettingsService portalSettingsService, IModuleStore moduleStore)
 {
     this.camundaService        = camundaService;
     this.memoryCacheService    = memoryCacheService;
     this.portalSettingsStore   = portalSettingsStore;
     this.portalSettingsService = portalSettingsService;
     this.moduleStore           = moduleStore;
 }
 public EmailAccountService(
     MongoDbContext dbContext,
     IMemoryCacheService memoryCacheService,
     IActivityLogService activityLogService)
 {
     _emailAccounts      = dbContext.EmailAccounts;
     _memoryCacheService = memoryCacheService;
     _activityLogService = activityLogService;
 }
Ejemplo n.º 9
0
 public IPDetailsService(
     SqlDbContext ctx,
     IIPInfoProvider ipInfoProvider,
     IMemoryCacheService memory
     )
 {
     _ctx            = ctx;
     _memory         = memory;
     _ipInfoProvider = ipInfoProvider;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// ctor
 /// </summary>
 public Versioning(
     HttpContextBase httpCtx,
     IFileSystem fileSystem,
     IFileWatcherService fswSvc,
     IMemoryCacheService memoryCacheService
     )
 {
     _httpCtx            = httpCtx;
     _fs                 = fileSystem;
     _fswSvc             = fswSvc;
     _memoryCacheService = memoryCacheService;
 }
Ejemplo n.º 11
0
        public async Task <IDynamicCollection <T> > GetOrCreateAsync <T>(
            string listName,
            Func <IQueryable <T>, IQueryable <T> > query    = null,
            Func <IEnumerable <T>, IEnumerable <T> > sorter = null
            )
            where T : IEntity
        {
            var collectionKey = GetCollectionCacheKey(listName);

            var result =
                IMemoryCacheService.Get <IDynamicCollection <T> >(collectionKey);

            if (result != null)
            {
                return(result);
            }

            var IRepository = IContainerService.Get <IRepository <T> >();

            var idsKey    = GetIdsCacheKey(listName);
            var entityIds = await ICacheService.GetAsync <List <string> >(idsKey);

            if (entityIds == null)
            {
                var queryable = IRepository.GetQueryable();

                if (query != null)
                {
                    queryable = query(queryable);
                }

                var entities = await IDatabaseService.QueryAsync(queryable);

                await IEntityCacheService.Push(entities);

                entityIds =
                    entities
                    .Select(x => x?.Id)
                    .ToList();
            }
            else
            {
                await IRepository.GetManyByIdAsync(entityIds);
            }

            result =
                IDynamicCollectionFactory
                .Create(entityIds, sorter);

            IMemoryCacheService.Set(collectionKey, result);

            return(result);
        }
Ejemplo n.º 12
0
 public DefaultAccessDispatcher
 (
     IMemoryCacheService memoryCache,
     IJwtService jwtService,
     IRefreshTokenRepository refreshTokenRepository,
     IStorage storage
 )
 {
     _memoryCache            = memoryCache;
     _jwtService             = jwtService;
     _refreshTokenRepository = refreshTokenRepository;
     _storage = storage;
 }
Ejemplo n.º 13
0
        public override async Task <T> GetAsync <T>(
            string key,
            Func <T> factory         = null,
            CacheOptions <T> options = null
            )
        {
            var cacheObj =
                _UseCacheAside
                                        ? IMemoryCacheService.Get <T>(key)
                                        : default(T);

            if (cacheObj is NotFound)
            {
                return(default(T));
            }

            var result = cacheObj == null ? default(T) : cacheObj;

            if (result != null)
            {
                return(result);
            }

            result = await IRedisGatewayService.GetAsync <T>(key);

            if (result == null)
            {
                if (factory != null)
                {
                    result = factory();
                }
            }

            if (result == null)
            {
                IMemoryCacheService.Set(key, NotFound.Shared);
                return(default(T));
            }

            if (_UseCacheAside)
            {
                IMemoryCacheService.Set(key, result, options);
            }

            await IRedisGatewayService.SetAsync(key, result);

            return(result);
        }
        public static T GetCacheObject(IMemoryCacheService cacheObj,
                                       CacheConfig config, string cacheKey)
        {
            T objectFromCache = default(T);

            if (!config.Enabled)
            {
                return(objectFromCache);
            }
            try
            {
                var response = (Cacheable <T>)cacheObj.Get(cacheKey);
                objectFromCache = response != null ? response.Model : default(T);
            }
            catch (Exception ex)
            {
                // LOG
            }
            return(objectFromCache);
        }
Ejemplo n.º 15
0
        public FileSystemService(
            IMemoryCacheService memoryCacheService,
            IConfigurationService configurationService
            ) : base(memoryCacheService, configurationService)
        {
            Name                    = "File System";
            ImagePath               = "avares://Jaya.Provider.FileSystem/Assets/Images/Computer-32.png";
            Description             = "View your local drives, inspect their properties and play with directories & files stored within them.";
            IsRootDrive             = true;
            ConfigurationEditorType = typeof(ConfigurationView);

            Configuration = this.configurationService.Get <FileSystemConfigModel>();
            if (Configuration == null)
            {
                Configuration = new FileSystemConfigModel {
                    IsProtectedFileVisible = false
                }
            }
            ;
        }
        public static void StoreCacheObject(T data, IMemoryCacheService cacheObj,
                                            CacheConfig config, string cacheKey)
        {
            if (!config.Enabled)
            {
                return;
            }

            var dataToCache = new Cacheable <T>
            {
                TTL   = DateTime.Now.AddMinutes(config.TimeToLiveMinutes),
                Model = data
            };

            try
            {
                cacheObj.Remove(cacheKey);
                cacheObj.Put(cacheKey, dataToCache);
            }
            catch (Exception ex)
            {
                // LOG
            }
        }
 public StatsController(IMemoryCacheService memoryCacheService)
 {
     _cacheService = memoryCacheService;
 }
Ejemplo n.º 18
0
 public EmailAccountService(
     ObjectDbContext dbContext,
     IMemoryCacheService memoryCacheService) : base(dbContext)
 {
     _memoryCacheService = memoryCacheService;
 }
Ejemplo n.º 19
0
 public ValuesController(IUserService userService, IMemoryCacheService cacheService)
 {
     this._userService  = userService;
     this._cacheService = cacheService;
 }
 public void Setup()
 {
     _fileManager        = Substitute.For <IFileManager>();
     _memoryCacheService = Substitute.For <IMemoryCacheService>();
 }
 public HomeController(IMemoryCacheService memoryCacheService)
 {
     this.memoryCacheService = memoryCacheService;
 }
Ejemplo n.º 22
0
 public HomeController(IDataProtectionProvider provider, IMemoryCacheService cache)
 {
     protector          = provider.CreateProtector("WebCore.HomeController.v1");
     MemoryCacheService = cache;
 }
Ejemplo n.º 23
0
 public SettingHelper(IMemoryCacheService memoryCacheService, IUmbracoContextFactory umbracoContextFactory)
 {
     _memoryCacheService    = memoryCacheService;
     _umbracoContextFactory = umbracoContextFactory;
 }
Ejemplo n.º 24
0
        protected readonly IConfigurationService configurationService; // Dependency #2

        protected JayaPluginBase(IMemoryCacheService memoryCacheService, IConfigurationService configurationService)
        {
            this.memoryCacheService   = memoryCacheService;   // Dependency #1
            this.configurationService = configurationService; // Dependency #2
        }
Ejemplo n.º 25
0
 public FriendService(IMemoryCacheService inMemoryCacheService)
 {
     InMemoryCacheService = inMemoryCacheService ?? throw new ArgumentNullException(nameof(inMemoryCacheService));
 }
 public CountriesController(ICountryService countryService, IMemoryCacheService memoryCacheService)
 {
     _countryService     = countryService;
     _memoryCacheService = memoryCacheService;
 }
Ejemplo n.º 27
0
 public ActivityLogTypeService(
     ObjectDbContext dbContext,
     IMemoryCacheService memoryCacheService) : base(dbContext)
 {
     _memoryCacheService = memoryCacheService;
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MutantService"/> class.
 /// </summary>
 /// <param name="dnaService">Service of DNA</param>
 /// <param name="dnaService">Service for Memory Cache</param>
 public MutantService(IDnaService dnaService, IMemoryCacheService memoryCacheService)
 {
     _dnaService         = dnaService;
     _memoryCacheService = memoryCacheService;
 }
Ejemplo n.º 29
0
 public ContentEventHandler(IMemoryCacheService memoryCacheService)
 {
     _memoryCacheService = memoryCacheService;
 }
Ejemplo n.º 30
0
 public TodoRepository(IMemoryCacheService memoryCacheService)
 {
     this.memoryCacheService = memoryCacheService;
 }