Skip to content

Caching Strategy #195

@KubrickCode

Description

@KubrickCode

VS Code API call caching, computed value memoization.

class CacheManager {
  get<T>(key: CacheKey): T | undefined;
  set<T>(key: CacheKey, value: T, ttl?: number): void;
  invalidate(pattern: string | RegExp): void;
}

// Cached Config Reader Decorator
class CachedConfigReader implements ConfigReader {
  getButtons(): ButtonConfig[] {
    const cached = this.cache.get<ButtonConfig[]>("buttons:current");
    if (cached) return cached;

    const buttons = this.reader.getButtons();
    this.cache.set("buttons:current", buttons, 5000); // 5s TTL
    return buttons;
  }
}

Reason: Performance + Consistency
Current: Calling the VS Code API every time getButtons() is called
Improvement: Cache + Invalidation Strategy

  • Eliminate unnecessary API calls
  • Ensure state consistency

Metadata

Metadata

Assignees

Labels

improvementImprovements to existing featuresrefactorRefactoring code

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions