import { Events } from '../events/Events.js';
/**
 * A class that caches user info in memory so the application reduces the number
 * of requests to the backend requesting a user info.
 */
class UserCache {
    cached = new Map();
    async getUser(organizationId, key) {
        const existing = this.cached.get(key);
        if (existing) {
            return existing;
        }
        const read = await this.requestUser(organizationId, key);
        this.cached.set(key, read);
        return read;
    }
    async requestUser(organizationId, key) {
        try {
            const result = await Events.Store.User.read(organizationId, key);
            return result;
        }
        catch {
            // ....
        }
        return undefined;
    }
}
const instance = new UserCache();
export default instance;
//# sourceMappingURL=UserCache.js.map