TypeDoc all the thngs
This commit is contained in:
9
src/support/cache/CacheFactory.ts
vendored
9
src/support/cache/CacheFactory.ts
vendored
@@ -13,10 +13,15 @@ import {Config} from "../../service/Config";
|
||||
import {Cache} from "./Cache"
|
||||
import {MemoryCache} from "./MemoryCache";
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
export class CacheFactory extends AbstractFactory {
|
||||
protected readonly logging: Logging
|
||||
protected readonly config: Config
|
||||
|
||||
/** true if we have printed the memory-based cache driver warning once. */
|
||||
private static loggedMemoryCacheWarningOnce = false
|
||||
|
||||
constructor() {
|
||||
@@ -52,6 +57,10 @@ export class CacheFactory extends AbstractFactory {
|
||||
return meta
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configured cache driver and return some Instantiable<Cache>.
|
||||
* @protected
|
||||
*/
|
||||
protected getCacheClass() {
|
||||
const CacheClass = this.config.get('server.cache.driver', MemoryCache)
|
||||
if ( CacheClass === MemoryCache && !CacheFactory.loggedMemoryCacheWarningOnce ) {
|
||||
|
||||
5
src/support/cache/MemoryCache.ts
vendored
5
src/support/cache/MemoryCache.ts
vendored
@@ -1,7 +1,12 @@
|
||||
import {Collection} from "@extollo/util"
|
||||
import {Cache} from "./Cache"
|
||||
|
||||
/**
|
||||
* An in-memory implementation of the Cache.
|
||||
* This is the default implementation for compatibility, but applications should switch to a persistent-backed cache driver.
|
||||
*/
|
||||
export class MemoryCache extends Cache {
|
||||
/** Static collection of in-memory cache items. */
|
||||
private static cacheItems: Collection<{key: string, value: string, expires?: Date}> = new Collection<{key: string; value: string, expires?: Date}>()
|
||||
|
||||
public fetch(key: string): string | Promise<string | undefined> | undefined {
|
||||
|
||||
Reference in New Issue
Block a user