@nova-fe/i18next-cache-backend
Version:
强大的 i18next 后端插件,具有 IndexedDB 缓存、批量加载和智能缓存策略
65 lines • 1.65 kB
TypeScript
export interface CacheBackendConfig {
server: {
port: number;
host: string;
apiPrefix: string;
};
cache: {
storage: 'indexeddb' | 'localstorage';
maxSize: number;
ttl: number;
namespace: string;
version?: string;
};
fetchStrategy: 'namespace' | 'bulk';
performance: {
batchSize: number;
retryAttempts: number;
timeout: number;
concurrency: number;
};
debug?: boolean;
offline?: boolean;
}
export interface CacheEntry<T = TranslationData> {
data: T;
timestamp: number;
version?: string;
ttl: number;
}
export interface TranslationData {
[key: string]: string | number | boolean | TranslationData;
}
export interface NamespaceData {
[namespace: string]: TranslationData;
}
export interface LanguageData {
[language: string]: NamespaceData;
}
export interface CacheStats {
size: number;
entries: number;
hitRate: number;
lastCleanup: number;
}
export interface RequestOptions {
language: string;
namespace: string;
fallbackLng?: string[];
}
export interface BulkRequestOptions {
languages: string[];
namespaces: string[];
}
export type CacheKey = string;
export type CacheValue = CacheEntry<TranslationData>;
export interface CacheProvider {
get(key: CacheKey): Promise<CacheValue | null>;
set(key: CacheKey, value: CacheValue): Promise<void>;
delete(key: CacheKey): Promise<void>;
clear(): Promise<void>;
keys(): Promise<CacheKey[]>;
size(): Promise<number>;
cleanup?(): Promise<void>;
}
//# sourceMappingURL=types.d.ts.map