/// <summary> /// 移除缓存 /// </summary> /// <param name="keys">缓存键集</param> public static void RemoveRange(IEnumerable <string> keys) { using (ICacheAdapter cacheAdapter = (ICacheAdapter)Activator.CreateInstance(_CacheImplType)) { cacheAdapter.RemoveRange(keys); } }
/// <summary> /// 移除缓存 /// </summary> /// <param name="key">键</param> public static void Remove(string key) { using (ICacheAdapter cacheAdapter = (ICacheAdapter)Activator.CreateInstance(_CacheImplType)) { cacheAdapter.Remove(key); } }
private SqlServerDataSource(string name, SqlConnectionStringBuilder connectionStringBuilder, SqlServerDataSourceSettings settings, SqlServerMetadataCache databaseMetadata, ICacheAdapter cache, ConcurrentDictionary <Type, object> extensionCache) : base(settings) { if (connectionStringBuilder == null) { throw new ArgumentNullException("connectionStringBuilder", "connectionStringBuilder is null."); } m_ConnectionBuilder = connectionStringBuilder; if (string.IsNullOrEmpty(name)) { Name = m_ConnectionBuilder.InitialCatalog ?? m_ConnectionBuilder.DataSource; } else { Name = name; } m_DatabaseMetadata = databaseMetadata; if (settings != null) { XactAbort = settings.XactAbort; ArithAbort = settings.ArithAbort; } m_ExtensionCache = extensionCache; m_Cache = cache; }
/// <summary> /// Creates a new data source with the provided cache. /// </summary> /// <param name="cache">The cache.</param> /// <returns></returns> public MySqlDataSource WithCache(ICacheAdapter cache) { var result = WithSettings(null); result.m_Cache = cache; return(result); }
internal GenericDbDataSource(string name, DbConnectionStringBuilder connectionStringBuilder, DataSourceSettings settings = null) : base(settings) { m_ConnectionBuilder = connectionStringBuilder ?? throw new ArgumentNullException(nameof(connectionStringBuilder)); Name = name; m_ExtensionCache = new ConcurrentDictionary <Type, object>(); m_Cache = DefaultCache; }
public GameModule( ICacheAdapter appCache, ISessionAdapter session, IResponseAdapter response) : base(appCache, session, response) { }
/// <summary> /// Initializes a new instance of the <see cref="BaseAppService"/> class. /// </summary> /// <param name="objectMapper">The object mapper.</param> /// <param name="cacheService">The cache service.</param> /// <param name="exceptionManager">The exception manager.</param> /// <param name="loggingService">The logging service.</param> public BaseAppService(IObjectMapperAdapter objectMapper, ICacheAdapter cacheService, IExceptionManagerAdapter exceptionManager, ILoggingServiceAdapter loggingService) { this.ObjectMapper = objectMapper; this.CacheService = cacheService; this.ExceptionManager = exceptionManager; this.LoggingService = loggingService; }
public AccountModule( ICacheAdapter appCache, ISessionAdapter session, IResponseAdapter response) : base(appCache, session, response) { }
/// <summary> /// Initializes a new instance of the <see cref="CourseModuleAppService"/> class. /// </summary> /// <param name="courseManager">The course manager.</param> /// <param name="objectMapper">The object mapper.</param> /// <param name="cacheService">The cache service.</param> /// <param name="exceptionManager">The exception manager.</param> /// <param name="loggingService">The logging service.</param> public CourseModuleAppService( ICourseDomainService courseManager, IModuleDomainService moduleManager, IModuleQuizDomainService moduleQuizManager, IDepartmentDomainService departmentManager, IObjectMapperAdapter objectMapper, ICacheAdapter cacheService, IExceptionManagerAdapter exceptionManager, ILoggingServiceAdapter loggingService, ICourseRegistrationDomainService courseRegistrationManager, IQuizDomainService quizManager, IAssignmentDomainService assignmentManager, ISubmissionDomainService submissionManager, IStudentDomainService studentManager) : base(objectMapper, cacheService, exceptionManager, loggingService) { this.CourseManager = courseManager; this.ModuleManager = moduleManager; this.DepartmentManager = departmentManager; this.CourseRegistrationManager = courseRegistrationManager; this.QuizManager = quizManager; this.AssignmentManager = assignmentManager; this.SubmissionManager = submissionManager; this.StudentManager = studentManager; }
public EnergyTankModule( ICacheAdapter appCache, ISessionAdapter session, IResponseAdapter response) : base(appCache, session, response) { }
public ProjectorServices(ICacheAdapter cache, IMessageBusAdapter bus, ILockProvider lockProvider, IServiceProvider serviceProvider) { Cache = cache ?? throw new ArgumentNullException(nameof(cache)); Bus = bus ?? throw new ArgumentNullException(nameof(bus)); LockProvider = lockProvider ?? throw new ArgumentNullException(nameof(lockProvider)); ServiceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); }
SQLiteDataSource(string?name, SQLiteConnectionStringBuilder connectionStringBuilder, SQLiteDataSourceSettings settings, SQLiteMetadataCache databaseMetadata, ICacheAdapter cache, ConcurrentDictionary <Type, object> extensionCache) : base(settings) { if (connectionStringBuilder == null) { throw new ArgumentNullException(nameof(connectionStringBuilder), $"{nameof(connectionStringBuilder)} is null."); } m_ConnectionBuilder = connectionStringBuilder; if (string.IsNullOrEmpty(name)) { Name = m_ConnectionBuilder.DataSource; } else { Name = name; } m_DatabaseMetadata = databaseMetadata; m_ExtensionCache = extensionCache; m_Cache = cache; if (settings != null) { EnforceForeignKeys = settings.EnforceForeignKeys; } }
/// <summary> /// 读取缓存 /// </summary> /// <typeparam name="T">数据类型</typeparam> /// <param name="key">键</param> /// <returns>值</returns> public static T Get <T>(string key) { using (ICacheAdapter cacheAdapter = (ICacheAdapter)Activator.CreateInstance(_CacheImplType)) { return(cacheAdapter.Get <T>(key)); } }
public TagRepository(ILogger <TagRepository> logger, LouisvilleDemographicsContext louisvilleDemographicsContext, ICacheAdapter cacheAdapter, CacheSettings cacheSettings) { _logger = logger; _louisvilleDemographicsContext = louisvilleDemographicsContext; _cacheAdapter = cacheAdapter; _cacheSettings = cacheSettings; }
public CharacterModule( ICacheAdapter appCache, ISessionAdapter session, IResponseAdapter response) : base(appCache, session, response) { }
/// <summary> /// Initializes a new instance of the <see cref="SecurityAppService"/> class. /// </summary> /// <param name="objectMapper">The object mapper.</param> /// <param name="cacheService">The cache service.</param> /// <param name="exceptionManager">The exception manager.</param> /// <param name="loggingService">The logging service.</param> public SecurityAppService( IObjectMapperAdapter objectMapper, ICacheAdapter cacheService, IExceptionManagerAdapter exceptionManager, ILoggingServiceAdapter loggingService) : base(objectMapper, cacheService, exceptionManager, loggingService) { }
/// <summary> /// Initializes a new instance of the <see cref="GenericDbDataSource" /> class. /// </summary> /// <param name="factory">The factory.</param> /// <param name="name">The name.</param> /// <param name="connectionStringBuilder">The connection string builder.</param> /// <param name="settings">Optional settings object.</param> /// <exception cref="ArgumentNullException">factory;factory is null. /// or /// connectionStringBuilder;connectionStringBuilder is null.</exception> public GenericDbDataSource(DbProviderFactory factory, string name, DbConnectionStringBuilder connectionStringBuilder, DataSourceSettings settings = null) : base(settings) { m_Factory = factory ?? throw new ArgumentNullException(nameof(factory)); m_ConnectionBuilder = connectionStringBuilder ?? throw new ArgumentNullException(nameof(connectionStringBuilder));; Name = name; m_ExtensionCache = new ConcurrentDictionary <Type, object>(); m_Cache = DefaultCache; }
public RequestCache( ICacheAdapter sessionCache, AsyncRPGDataContext dbContext) { m_sessionCache = sessionCache; m_dbContext = dbContext; m_requestRoomCache = null; }
public TaskFilter( string?filterExpression, ICacheAdapter?cache = null) { _cache = cache ?? new DumbCache(); var matcher = ExpressionMatcher(filterExpression, true); _isValid = matcher is not null; _isMatch = matcher ?? AlwaysFalse; }
public RestModule( ICacheAdapter appCache, ISessionAdapter session, IResponseAdapter response) { this.Application = appCache; this.Session = session; this.Response = response; }
public CachedCommandDispatcher(ICacheKeyProvider cacheKeyProvider, IFrameworkCommandDispatcher commandDispatcher, ICacheOptionsProvider cacheOptionsProvider, ICacheAdapter cacheAdapter) { _cacheKeyProvider = cacheKeyProvider; _commandDispatcher = commandDispatcher; _cacheOptionsProvider = cacheOptionsProvider; _cacheAdapter = cacheAdapter; }
/// <summary> /// Initializes a new instance of the <see cref="StaffAppService"/> class. /// </summary> /// <param name="staffManager">The staff manager.</param> /// <param name="objectMapper">The object mapper.</param> public StaffAppService( IStaffDomainService staffManager, IObjectMapperAdapter objectMapper, ICacheAdapter cacheService, IExceptionManagerAdapter exceptionManager, ILoggingServiceAdapter loggingService) : base(objectMapper, cacheService, exceptionManager, loggingService) { this.StaffManager = staffManager; }
/// <summary> /// Initializes a new instance of the <see cref="ScheduleModuleAppService"/> class. /// </summary> /// <param name="ScheduleManager">The Schedule manager.</param> /// <param name="objectMapper">The object mapper.</param> /// <param name="cacheService">The cache service.</param> /// <param name="exceptionManager">The exception manager.</param> /// <param name="loggingService">The logging service.</param> public ScheduleAppService( IScheduleDomainService ScheduleManager, IObjectMapperAdapter objectMapper, ICacheAdapter cacheService, IExceptionManagerAdapter exceptionManager, ILoggingServiceAdapter loggingService) : base(objectMapper, cacheService, exceptionManager, loggingService) { this.ScheduleManager = ScheduleManager; }
/// <summary> /// Initializes a new instance of the <see cref="UserAppService"/> class. /// </summary> /// <param name="userManager">The user manager.</param> /// <param name="objectMapper">The object mapper.</param> /// <param name="cacheService">The cache service.</param> /// <param name="exceptionManager">The exception manager.</param> /// <param name="loggingService">The logging service.</param> public UserAppService( IUserDomainService userManager, IObjectMapperAdapter objectMapper, ICacheAdapter cacheService, IExceptionManagerAdapter exceptionManager, ILoggingServiceAdapter loggingService) : base(objectMapper, cacheService, exceptionManager, loggingService) { this.UserManager = userManager; }
/// <summary> /// 写入缓存(有过期时间) /// </summary> /// <typeparam name="T">数据类型</typeparam> /// <param name="key">键</param> /// <param name="value">值</param> /// <param name="expiredTime">过期时间</param> public static void Set <T>(string key, T value, DateTime expiredTime) { using (ICacheAdapter cacheAdapter = (ICacheAdapter)Activator.CreateInstance(_CacheImplType)) { lock (_Sync) { cacheAdapter.Set(key, value, expiredTime); } } }
public StateMachineManager( ICacheAdapter cacheAdapter, ITablesRepository tablesRepository, ITablesUsagePolicy tablesUsagePolicy) { _cache = cacheAdapter ?? throw new ArgumentNullException(nameof(cacheAdapter)); _tables = tablesRepository ?? throw new ArgumentNullException(nameof(tablesRepository)); _tablesUsagePolicy = tablesUsagePolicy ?? throw new ArgumentNullException(nameof(tablesUsagePolicy)); _defaultCacheExpiration = TimeSpan.FromMinutes(DefaultCacheExpirationInMinutes); }
/// <summary> /// Initializes a new instance of the <see cref="CourseModuleAppService"/> class. /// </summary> /// <param name="courseManager">The course manager.</param> /// <param name="objectMapper">The object mapper.</param> /// <param name="cacheService">The cache service.</param> /// <param name="exceptionManager">The exception manager.</param> /// <param name="loggingService">The logging service.</param> public BaseQuestionTopicAppService( IBaseQuestionTopicDomainService baseQuestionTopicManager, IObjectMapperAdapter objectMapper, ICacheAdapter cacheService, IExceptionManagerAdapter exceptionManager, ILoggingServiceAdapter loggingService) : base(objectMapper, cacheService, exceptionManager, loggingService) { this.BaseQuestionTopicManager = baseQuestionTopicManager; }
/// <summary> /// 是否存在缓存 /// </summary> /// <param name="key">键</param> /// <returns>是否存在</returns> public static bool Exists(string key) { using (ICacheAdapter cacheAdapter = (ICacheAdapter)Activator.CreateInstance(_CacheImplType)) { lock (_Sync) { return(cacheAdapter.Exists(key)); } } }
/// <summary> /// Load all dependencies in the Hosted Service. /// </summary> /// <param name="triasCommunicator">Trias Communicator service</param> /// <param name="cacheAdapter">Adapter for the Cache</param> /// <param name="logger">Service to log events</param> public TripLogger( ITriasCommunicator triasCommunicator, ICacheAdapter cacheAdapter, ILogger <TripLogger> logger ) { _triasCommunicator = triasCommunicator; _triasCommunicator.RequestFinished += OnTriasCommunicatorRequestFinished; _cacheAdapter = cacheAdapter; _logger = logger; }
/// <summary> /// Initializes a new instance of the <see cref="UnitModuleAppService"/> class. /// </summary> /// <param name="unitManager">The unit manager.</param> /// <param name="objectMapper">The object mapper.</param> /// <param name="cacheService">The cache service.</param> /// <param name="exceptionManager">The exception manager.</param> /// <param name="loggingService">The logging service.</param> public VideoAppService( IObjectMapperAdapter objectMapper, ICacheAdapter cacheService, IExceptionManagerAdapter exceptionManager, ILoggingServiceAdapter loggingService, IVideoDomainService iVideoDomainService) : base(objectMapper, cacheService, exceptionManager, loggingService) { _iVideoDomainService = iVideoDomainService; }
public MyQueryService(ILoggerFactory loggerFactory, ICacheAdapter cache, IEntityStore entityStore) { if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } _cache = cache ?? throw new ArgumentNullException(nameof(cache)); _entityStore = entityStore ?? throw new ArgumentNullException(nameof(entityStore)); _logger = loggerFactory.CreateLogger(GetType()); }
private SQLiteDataSource(string name, SQLiteConnectionStringBuilder connectionStringBuilder, SQLiteDataSourceSettings settings, SQLiteMetadataCache databaseMetadata, ICacheAdapter cache, ConcurrentDictionary<Type, object> extensionCache) : base(settings) { if (connectionStringBuilder == null) throw new ArgumentNullException("connectionStringBuilder", "connectionStringBuilder is null."); m_ConnectionBuilder = connectionStringBuilder; if (string.IsNullOrEmpty(name)) Name = m_ConnectionBuilder.DataSource; else Name = name; m_DatabaseMetadata = databaseMetadata; m_ExtensionCache = extensionCache; m_Cache = cache; }
public static WorldBuilder GetWorldBuilder( AsyncRPGDataContext db_context, ICacheAdapter cache) { WorldBuilder worldBuilder = (WorldBuilder)cache["world_builder"]; if (worldBuilder == null) { worldBuilder = new WorldBuilder(); worldBuilder.Initialize(db_context); cache["world_builder"] = worldBuilder; } return worldBuilder; }
public static World GetWorld( AsyncRPGDataContext db_context, ICacheAdapter cache, int game_id) { string world_identifier = GetWorldCacheIdentifier(game_id); World world = (World)cache[world_identifier]; if (world == null) { world = WorldBuilderCache.GetWorldBuilder(db_context, cache).LazyLoadWorld(db_context, game_id); cache[world_identifier] = world; } return world; }
public static bool BuildWorld( AsyncRPGDataContext db_context, ICacheAdapter cache, int game_id, out string result) { World world = null; bool success = WorldBuilderCache.GetWorldBuilder(db_context, cache).BuildWorld(db_context, game_id, out world, out result); if (success) { string world_identifier = GetWorldCacheIdentifier(game_id); cache[world_identifier] = world; } return success; }
public bool ProcessRequest( string connection_string, ICacheAdapter sessionCache, out string result_code) { bool success = false; result_code = ErrorMessages.GENERAL_ERROR; // Remember the connection string we're using // so that request processors internal to this one // can use it as well m_connectionString = connection_string; while (!success && m_retryCount > 0) { System.Data.Common.DbTransaction dbTransaction = null; AsyncRPGDataContext dbContext = new AsyncRPGDataContext(connection_string); RequestCache requestCache = new RequestCache(sessionCache, dbContext); m_retryCount--; try { // Open the db connection immediately dbContext.Connection.Open(); // Create a transaction for the request processor. // If anything fails along the way, roll back everything. dbTransaction = dbContext.Connection.BeginTransaction(IsolationLevel.ReadCommitted); // Tell the context about the transaction so that it doesn't create one of it's own dbContext.Transaction = dbTransaction; // Start off assuming success result_code = SuccessMessages.GENERAL_SUCCESS; // Attempt to process the request if (ProcessRequestInternal( requestCache, out result_code)) { // Save any modified objects back into the DB requestCache.WriteDirtyObjectsToDatabase(); // Commit the transaction to the DB up success dbTransaction.Commit(); dbTransaction = null; success = true; } else { // Something failed (in a controlled manner) dbTransaction.Rollback(); dbTransaction = null; } } catch (System.Transactions.TransactionAbortedException ex) { // Our attempt to rollback a failed transaction failed. // Possible data corruption :( result_code = ErrorMessages.DB_ERROR + "(Transaction Aborted:" + ex.Message + ")"; success = false; // Don't bother retrying in this case m_retryCount = 0; } catch (System.Exception ex) { // An unexpected error occurred // Attempt to rollback any db changes if any were made if (dbTransaction != null) { dbTransaction.Rollback(); dbTransaction = null; } // Don't bother retrying in this case result_code = ex.Message; success = false; // Don't bother retrying in this case m_retryCount = 0; } finally { // In all cases, make sure to close the connection to the DB if (dbContext.Connection.State == ConnectionState.Open) { dbContext.Connection.Close(); } dbContext = null; } } return success; }
private PostgreSqlDataSource(string name, NpgsqlConnectionStringBuilder connectionBuilder, PostgreSqlDataSourceSettings settings, PostgreSqlMetadataCache databaseMetadata, ICacheAdapter cache, ConcurrentDictionary<Type, object> extensionCache) : base(settings) { if (connectionBuilder == null) throw new ArgumentNullException(nameof(connectionBuilder), $"{nameof(connectionBuilder)} is null."); m_ConnectionBuilder = connectionBuilder; if (string.IsNullOrEmpty(name)) Name = m_ConnectionBuilder.Database; else Name = name; m_DatabaseMetadata = databaseMetadata; m_ExtensionCache = extensionCache; m_Cache = cache; }
public USXmlStateProvinceService(ICacheAdapter cacheAdapter) { _cacheAdapter = cacheAdapter; }
/// <summary> /// Craetes a new data source with the provided cache. /// </summary> /// <param name="cache">The cache.</param> /// <returns></returns> public SQLiteDataSource WithCache(ICacheAdapter cache) { var result = WithSettings(null); result.m_Cache = cache; return result; }
public static void ClearWorldBuilder(ICacheAdapter cache) { cache.Remove("world_builder"); }
/// <summary> /// Craetes a new data source with the provided cache. /// </summary> /// <param name="cache">The cache.</param> /// <returns></returns> public OleDbSqlServerDataSource WithCache(ICacheAdapter cache) { var result = WithSettings(null); result.m_Cache = cache; return result; }
private OleDbSqlServerDataSource(string name, OleDbConnectionStringBuilder connectionStringBuilder, SqlServerDataSourceSettings settings, OleDbSqlServerMetadataCache databaseMetadata, ICacheAdapter cache, ConcurrentDictionary<Type, object> extensionCache) : base(settings) { if (connectionStringBuilder == null) throw new ArgumentNullException("connectionStringBuilder", "connectionStringBuilder is null."); m_ConnectionBuilder = connectionStringBuilder; if (string.IsNullOrEmpty(name)) Name = m_ConnectionBuilder.DataSource; else Name = name; m_DatabaseMetadata = databaseMetadata; if (settings != null) { XactAbort = settings.XactAbort; ArithAbort = settings.ArithAbort; } m_ExtensionCache = extensionCache; m_Cache = cache; }
public static void ClearWorld(ICacheAdapter cache, int game_id) { string world_identifier = GetWorldCacheIdentifier(game_id); cache.Remove(world_identifier); }