Skip to content

Caching Strategy #195

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

improvementImprovements to existing featuresrefactorRefactoring code

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions