Error response enhancements, CoreID auth client backend
This commit is contained in:
9
src/util/cache/Cache.ts
vendored
9
src/util/cache/Cache.ts
vendored
@@ -1,4 +1,5 @@
|
||||
import {Awaitable} from '../support/types'
|
||||
import {Safe} from '../support/Safe'
|
||||
|
||||
/**
|
||||
* Abstract interface class for a cached object.
|
||||
@@ -11,6 +12,14 @@ export abstract class Cache {
|
||||
*/
|
||||
public abstract fetch(key: string): Awaitable<string|undefined>;
|
||||
|
||||
/**
|
||||
* Fetch a value from the cache by its key as a Safe value.
|
||||
* @param key
|
||||
*/
|
||||
public async safe(key: string): Promise<Safe> {
|
||||
return new Safe(await this.fetch(key))
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the given value in the cache by key.
|
||||
* @param {string} key
|
||||
|
||||
Reference in New Issue
Block a user