mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 10:21:24 +00:00
refactor: rename to openclaw
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { ChannelDirectoryEntryKind, ChannelId } from "../../channels/plugins/types.js";
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
|
||||
type CacheEntry<T> = {
|
||||
value: T;
|
||||
@@ -21,11 +21,11 @@ export function buildDirectoryCacheKey(key: DirectoryCacheKey): string {
|
||||
|
||||
export class DirectoryCache<T> {
|
||||
private readonly cache = new Map<string, CacheEntry<T>>();
|
||||
private lastConfigRef: MoltbotConfig | null = null;
|
||||
private lastConfigRef: OpenClawConfig | null = null;
|
||||
|
||||
constructor(private readonly ttlMs: number) {}
|
||||
|
||||
get(key: string, cfg: MoltbotConfig): T | undefined {
|
||||
get(key: string, cfg: OpenClawConfig): T | undefined {
|
||||
this.resetIfConfigChanged(cfg);
|
||||
const entry = this.cache.get(key);
|
||||
if (!entry) return undefined;
|
||||
@@ -36,7 +36,7 @@ export class DirectoryCache<T> {
|
||||
return entry.value;
|
||||
}
|
||||
|
||||
set(key: string, value: T, cfg: MoltbotConfig): void {
|
||||
set(key: string, value: T, cfg: OpenClawConfig): void {
|
||||
this.resetIfConfigChanged(cfg);
|
||||
this.cache.set(key, { value, fetchedAt: Date.now() });
|
||||
}
|
||||
@@ -47,12 +47,12 @@ export class DirectoryCache<T> {
|
||||
}
|
||||
}
|
||||
|
||||
clear(cfg?: MoltbotConfig): void {
|
||||
clear(cfg?: OpenClawConfig): void {
|
||||
this.cache.clear();
|
||||
if (cfg) this.lastConfigRef = cfg;
|
||||
}
|
||||
|
||||
private resetIfConfigChanged(cfg: MoltbotConfig): void {
|
||||
private resetIfConfigChanged(cfg: OpenClawConfig): void {
|
||||
if (this.lastConfigRef && this.lastConfigRef !== cfg) {
|
||||
this.cache.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user