TypeDoc all the thngs

This commit is contained in:
2021-03-25 08:50:13 -05:00
parent 7cb0546b01
commit fad1184afe
52 changed files with 976 additions and 3 deletions

View File

@@ -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 ) {

View File

@@ -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 {