28 lines
960 B
TypeScript
28 lines
960 B
TypeScript
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.'
|
|
}
|
|
}
|