@yihuangdb/storage-object
Version:
A Node.js storage object layer library using Redis OM
110 lines • 3.5 kB
TypeScript
import { StorageObject, StorageOptions } from './storage';
import { SchemaConfig } from './schema';
import { PerformanceMetric } from './performance-profiler';
export interface SchemaMetadata {
name: string;
version: number;
schema: SchemaConfig;
options?: StorageOptions;
createdAt: Date;
updatedAt: Date;
lastAccessedAt: Date;
attributes: {
fieldCount: number;
indexedFieldCount: number;
fields: Record<string, any>;
};
statistics: {
objectCount: number;
createCount: number;
readCount: number;
updateCount: number;
deleteCount: number;
totalOperations: number;
averageObjectSize: number;
};
performance: {
averageCreateTime: number;
averageReadTime: number;
averageUpdateTime: number;
averageDeleteTime: number;
slowestOperation: {
type: string;
duration: number;
timestamp: Date;
};
};
status: 'active' | 'inactive' | 'deprecated';
}
export interface RegistryOptions {
persistMetadata?: boolean;
redisUrl?: string;
enableCache?: boolean;
cacheSize?: number;
cacheTTL?: number;
enableProfiling?: boolean;
lazyLoad?: boolean;
compressionEnabled?: boolean;
}
export declare class OptimizedSchemaRegistry {
private static instance;
private registeredSchemas;
private storageInstances;
private client?;
private options;
private registryKey;
private cache;
private cacheSize;
private cacheTTL;
private accessFrequency;
private hotSchemas;
private pendingOperations;
private cleanupInterval?;
private hotSchemaInterval?;
private pendingPersistence?;
private constructor();
static getInstance(options?: RegistryOptions): OptimizedSchemaRegistry;
private initializeRedis;
private loadPersistedSchemas;
register(name: string, schema: SchemaConfig, options?: StorageOptions): Promise<SchemaMetadata>;
private performRegistration;
private analyzeSchema;
private persistSchemaAsync;
getStorage<T extends Record<string, any> = any>(name: string): Promise<StorageObject<T> | null>;
private lazyLoadSchema;
registerStorageInstance<T extends Record<string, any> = any>(name: string, storage: StorageObject<T>): Promise<void>;
private createStorageInstance;
private wrapStorageMethods;
private updateStatistics;
private updateLastAccessed;
private schemasEqual;
private getCached;
private setCached;
private cacheSchema;
private invalidateCache;
private evictLRU;
private cleanupCache;
private trackAccess;
private detectHotSchemas;
private compress;
private decompress;
getSchemaMetadata(name: string): Promise<SchemaMetadata | null>;
getAllSchemas(): Promise<SchemaMetadata[]>;
getPerformanceReport(): {
cacheStats: {
size: number;
hits: number;
misses: number;
hitRate: number;
};
hotSchemas: string[];
registryMetrics: PerformanceMetric[];
bottlenecks: any[];
};
updateObjectCount(name: string): Promise<void>;
clearAllPersistedSchemas(): Promise<void>;
shutdown(): Promise<void>;
static reset(): Promise<void>;
}
export declare function getOptimizedSchemaRegistry(options?: RegistryOptions): OptimizedSchemaRegistry;
//# sourceMappingURL=schema-registry-optimized.d.ts.map