You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lib/src/support/cache/CacheFactory.ts

28 lines
960 B

import {Instantiable, FactoryProducer} from '../../di'
import {InMemCache, Maybe} from '../../util'
import {Cache} from '../../util'
import {ConfiguredSingletonFactory} from '../../di/factory/ConfiguredSingletonFactory'
/**
* Dependency container factory that matches the abstract Cache token, but
* produces an instance of whatever Cache driver is configured in the `server.cache.driver` config.
*/
@FactoryProducer()
export class CacheFactory extends ConfiguredSingletonFactory<Cache> {
protected getConfigKey(): string {
return 'server.cache.driver'
}
protected getDefaultImplementation(): Instantiable<Cache> {
return InMemCache
}
protected getAbstractImplementation(): any {
return Cache
}
protected getDefaultImplementationWarning(): Maybe<string> {
return 'You are using the default memory-based cache driver. It is recommended you configure a persistent cache driver instead.'
}
}