forceCalendar
API Reference

LRUCache

API reference for the LRUCache class.

import { LRUCache } from '@forcecalendar/core';

Constructor

new LRUCache(maxSize: number)

Methods

MethodSignatureReturns
get(key: string) => any | undefinedValue (moves to most-recent)
put(key: string, value: any) => void
has(key: string) => boolean
delete(key: string) => boolean
clear() => void
keys() => Iterator<string>Key iterator
getStats() => CacheStatsStatistics

CacheStats

interface CacheStats {
  size: number;
  maxSize: number;
  hits: number;
  misses: number;
  evictions: number;
  hitRate: number;
}

Implementation

Uses JavaScript Map insertion order semantics for O(1) operations:

  • get(): Delete and re-insert to move to end (most recent)
  • put(): Insert at end; if over capacity, delete first entry (least recent)
  • All operations are O(1) amortized